I'm using playframework -v 1.2.4, and using the morphia plugin. When I run play test, and connect with mongolab db, an exception is thrown with the following error:
Oops: RuntimeException
An unexpected error occured caused by exception RuntimeException:
MongoDB authentication failed: mydb
My application.conf as follows..,
application.mode=dev
%prod.application.mode=prod
morphia.db.host=ds033187.mongolab.com
morphia.db.port=33187
morphia.db.username=demo
morphia.db.password=demo
morphia.db.name=mydb
But the above credentials are able to connect with mongodb
D:\mongodb-win32-i386-2.0.1\bin>mongo ds033187.mongolab.com:33187/mydb -u demo -p demo
MongoDB shell version: 2.0.1
connecting to: ds033187.mongolab.com:33187/mydb
>
But i get connection with mongodb shell. Why i'am getting this error?
I am assuming that you are using the PlayMorphia module, and taking a quick look at the documentation, it uses "morphia.db.seeds" instead of "morphia.db.host".
It could be that, since "seeds" is not specified, the morphia module is connecting to the localhost.
had the exact same problem.
i suppose you added the user via
use admin
db.addUser( "user", "pw" )
however, play morphia does seem to authenticate against the very db you're using, not against the admin db. the following solved my problem:
/path/to/mongo
use admin
db.auth( "user", "pw" )
use myDatabase
db.addUser( "user", "pw" )
now it should work :)
Related
I have created a heroku posgresql database and I am trying to connect my Android app to this database. I am using Android Studio for making the Android app. I have used the following code for creating the connection:
try {
Class.forName("org.postgresql.Driver");
Connection db = DriverManager.getConnection(dbUrl);
}
catch(Exception e){
//handles exception
}
When I execute this code I get the following error: Something unusual has occurred tot cause the driver to fail. Please report this exception.
This is the driver I use: posgresql-42.2.12
The heroku database has version 12.2
Android studio has java version 1.8
I am not sure if the driver is in the classpath and I am not sure how to check this. I added the driver to the project this way: app > New > Module > Import .JAR/.AAR Package (here I selected the driver).
To check if the Driver is registered in DriverManager I used this code:
Enumeration<Driver> drivers = DriverManager.getDrivers();
drivers.nextElement().getClass().getName();
This gives: org.postgresql.Driver
To check if the Driver understandes the URL I used this code:
DriverManager.getDriver(dbUrl).getClass().getName();
This also gives org.posgresql.Driver so I think the Driver is registered to the DriverManager and should be able to connect to the database using the URL. I just really don't know why I keep getting an error when I try to connect with the database.
So why does the error occur and how can I resolve the issue?
My first guess would be a malformed connection string. Are you using a proper JDBC URL (i.e. it starts with jdbc:) for dbUrl? Also make sure you include sslmode=require.
In addition, please be aware that the database URL is managed by Heroku and will change under certain circumstances. You can read more about using Heroku Postgres from outside of Heroku in this DevCenter article.
I`m trying to connect to my PostgreSQL database. What I create a connection and click the button "Test", I receive an error message. I can connect to this db via pgadmin without any problems, so it is not a connection or credentials issue
I`m using Pentaho kettle 8.3, Windows, java version "1.8.0_231"
Error connecting to database [Name] :org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database
Error connecting to database: (using class org.postgresql.Driver)
Ошибка при попытке подсоединения.
Full error stack: https://pastebin.com/cLiB288e
Try to add postgresql-42.1.1.jar in the /lib folder of PDI, restart the spoon and try again.
i faced 2 issues myself connecting to PostgreSQL few months back and following 2 things helped me
1.add postgres-42.1.1jar file in the 'lib' folder under PDI and restart the spoon.
if the normal JDBC connection convention does not work for you try below tip
while configuring the connection specify host name as follows
{HOST IP}:{HOST PORT}/{instance name}?
I'm trying to connect to hive with jdbc. I keep getting this error. I tried looking it up but could not hind anything useful .
This is my connection string:
jdbc:hive2://hostname.xxx.com:10000/default;principal=hive/hostname.xxx.com#HADOOP_ENV.COM
What is this error: java.lang.NoSuchMethodError: org.apache.hadoop.security.authentication.util.KerberosUtil.hasKerberosTicket(Ljavax/security/auth/Subject;)Z
That method exists in Hadoop 2.8 but not in Hadoop 2.7 -- so my guess is that your project dependencies are not aligned with whatever version of Hadoop you have in Production.
Code in trunk
https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosUtil.java
code in branch-2.8.0
https://github.com/apache/hadoop/blob/branch-2.8.0/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosUtil.java
code in branch-2.7.4
https://github.com/apache/hadoop/blob/branch-2.7.4/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosUtil.java
Kerberos is an authentication protocol that is used by Hive server (https://en.wikipedia.org/wiki/Kerberos_(protocol))
The problem you are setting is more about a missing library in our pom.xml. Have you include <artifactId>hive-jdbc</artifactId> ?
I think your keberos ticket is not generated properly
Can you try running these two commands in order from the user you are trying to connect:
kdestroy (deleted any kerberos ticket generated before)
kinit (generates a new ticket)
Then try to connect again.
Spring-roo can't be connect to MySQL
when i execute command database reverse engineer --schema test --package then it give error:
Could not initialize class com.mysql.jdbc.Connection...
Image of error:
You need 2 things:
Configure connection info in project in src/main/resources/META-INF/spring/database.properties file. Spring Roo uses it to connect DB.
Make JDBC driver accessible by Spring Roo installing it in OSGi environ ( see manual section about it )
Good luck!
I'm trying to make maven project which should work with oracle database.
First I tried to connect database to DB Browser in IDEA, but I've no idea how to use it in code if it's even possible. However I use following java code:
Base.open("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:#localhost:1521:XE", "SYSTEM", "pass");
it doesn't run with error Failed to connect to JDBC URL:
jdbc:oracle:thin:#localhost:1521:XE Caused by: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified.
But according to connection info in DB browser it's written right. What's going wrong?
Problem solved by following code before Base.open(...);: Locale.setDefault(Locale.ENGLISH);