Access denied for user 'root'#'localhost' (using password: YES) - java

Hi I'm working on a Liferay portlet that accesses the database using JPA. I'm using Tomcat 7 and MySQL.
This portlet works fine in my machine but when I move the portlet to a test environment in another server and try to use it in the test portal I get the following error:
Access denied for user 'root'#'localhost' (using password: YES)
The database connection database in my persistence.xml is ok.
I tried putting wrong connection data in the persistence.xml to see if the error changed but it didn't. For example I set the user as "wronguser" and when I deployed the portlet and tried to use it again I got exactly the same error:
Access denied for user 'root'#'localhost' (using password: YES)
Even if I change the database name or URL the error is always the same. It's like something is not getting updated. I tried deleting the Tomcat temp folder but didn't help.
Any ideas?
Thanks in advance.

I tried putting wrong connection data in the persistence.xml to see if
the error changed but it didn't. For example I set the user as
"wronguser" and when I deployed the portlet and tried to use it again
I got exactly the same error:
This just shows that the username/password given to mysql at the end is not coming from your configuration file as expected, but from to-be-identified-elsewhere.
Until you see mysql complaining about "wronguser" not being able to connect, this is the first roadblock to clear, and the problem is most likely in the application setup, not in mysql.
Should the mysql server complain later about privileges for "wronguser", then sure, the area to investigate then will be grants for this user, but you need to convey the proper user/host/password information to the server first.

Related

createSQLException Error while in Configuring Data Source with Weblogic

I am trying to configure DataSources with WebLogic 10.3 and database is MySQL Server 5.5 , On entering the following
Driver Class Name ="com.mysql.jdbc.Driver"
url =jdbc:mysql://localhost:3306/weblogicdb
Database User Name =root (User name of Database MySql Server)
Password =123(Password name of Database MySql Server)
Confirm Password =123
and on clicking TestConfiguration, I get the following error.
Connection test failed.
Message icon - Error Unknown database 'weblogicdb'<br/>com.mysql.jdbc.SQLError.createSQLException(SQLError.java:930)
<br/>com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2864)
<br/>com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:806)
<br/>com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3263)
<br/>com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1176)
<br/>com.mysql.jdbc.Connection.createNewIO(Connection.java:2638)
<br/>com.mysql.jdbc.Connection.<init>(Connection.java:1525)
<br/>com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:260)
<br/>com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:505)
<br/>com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:369)
<br/>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
<br/>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>java.lang.reflect.Method.invoke(Method.java:597)
<br/>org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
<br/>org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
<br/>org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
<br/>org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
<br/>org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
<br/>org.apache.beehive.netui.pageflow.internal.FlowControllerAction.execute(FlowControllerAction.java:52)<br/>...
I was looking into many blogs and previously asked questions, where they it could be because of username and password being incorrect. But that is not the issue in my case, I have rechecked it. on using the same username and password, I was able to log into my MySQL database.
Kindly help me in configuring the system.
Error stack clearly says that:
Message icon - Error Unknown database 'weblogicdb'
It seems you have input a wrong database name.
You might be succeeding with username/passwords to MySQL server.
But the server might have multiple databases in it and 'weblogicdb' is not the correct database name you are trying to connect to.
To see what databases the MySQL Server has in it, execute the following command either using java or any other MySQL clients like MySQL command line, SQLyog, PHPMyAdmin etc.
show databases();
This statement should result all the databases available.
Identify the appropriate one for your program and use the same in your code.
To connect through java to execute the above statement, db url should be:
url =jdbc:mysql://localhost:3306/?user=usernamevalue&password=passwordvalue

Yet another "Access denied for user" error..but I can log in directly to remote server from command line

Java 1.7
Spring 3.1.1 with Spring-WS 2.1.1
Joda
Hibernate 3.6
MySQL 5.0.51a
Maven 3
Tomcat 7
Eclipse 3.7
Greetings all...
Just another 'Access denied for user 'foo'#'localhost' error being thrown by my webapp, but with a twist.
I run both an instance of MySQL on my (duh) local machine for development, and another on my remote server.
Both instances have a database 'mydb' and two tables with identical names and structures.
On the local instance I use root.
On the remote machine I have issued the following sequence:
CREATE USER 'fubar'#'localhost' IDENTIFIED BY 'mypwd';
CREATE USER 'fubar'#'%' IDENTIFIED BY 'mypwd';
CREATE USER 'fubar'#'my.remote.server.com' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'localhost' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'%' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'my.remote.server.com' IDENTIFIED BY 'mypwd';
FLUSH PRIVILEGES;
I've confirmed with a 'select * from mysql.db' that three new rows appear and that all the appropriate fields have 'Y' values.
On the local machine from within a Command Prompt pane I can issue:
mysql -u fubar -p -h my.remote.server.com ,
reply with the password and get connected to the remote db.
Executing my java program fails with the famous
'Access denied for user 'fubar'#'localhost'
when url is adjusted to point to remote server
Using the following as part of my db.properties file in my Eclipse project:
hibernate.connection.url=jdbc:mysql://localhost:3306/mydb
hibernate.connection.username=root
hibernate.connection.password=myrootpwd
execution works great
execution fails with the dreaded error when using this:
hibernate.connection.url=jdbc:mysql://my.remote.servier.com:3306/mydb
hibernate.connection.username=fubar
hibernate.connection.password=mypwd
So I am stumped. How is that I can connect directly to the remote instance of MySQL server using the command line but not in my db.properties file?
TIA,
Still-learning Stev
I got into the same issue and its the wrong password that created the whole issue...
You can use the standalone java program code in the below link to test your connection and make sure it works first...
http://www.mkyong.com/jdbc/how-to-connect-to-mysql-with-jdbc-driver-java/

Glassfish 4 no password credential for resource

I have set up a project to use Glassfish 4 with a resource that links back to a MySql database and I am using Eclipse Keplar. I have set up the connection pool with the relevant details and pinging it from the glassfish admin page succeeds. I have an EJB project with JPA set up to access the resource but when access is atempted either in a browser or Eclipse I get a "No database selected" error.
After searching around I found that there are issues with the Url parameter of the pool and renaming that parameter to URL might solve it. the post I found also suggested that I enter the connection string as he suspected that different calls were being made and the string was not getting constructed correctly outside of Glassfish. I did these things but I then get an error "No Password Credential" even though I do have the password entered in the connection string.
Has anyone else encountered this and have any advice as to what the problem is and how I can solve it?
For me, editing the URL and Url parameters didn't work. However after restarting Glassfish (domain), the problem disappeared.
I have figured this out and it was the url value that needed to be set correctly. I didn't need it all but I did need to set the server and database name on it:
jdbc:mysql://localhost:3306/<DB Name Here>
I had changed the parameter name to URL from Url but it turns out that this is not required.I have no idea why this step is required as the values are all there in other parameters and the ping succeeds from the admin pages.
MYSQL and Glassfish.
In glassfish 4.0 if "No password credential found" error appears whenever you try to ping, it most probably means, you did not setup password(you gave empty password) when you first installed mysql server on your system, glassfish4.0 has a problem with empty password. Either you need to reset the password or uninstall the mysql server completely, and then re-install, by giving new password. To uninstall the mysql-server completely please flow this link, https://askubuntu.com/questions/640899/how-do-i-uninstall-mysql completely it worked for me.
I am using Payara 5.181 and after I changed some properties and clicked flush, it throwed exceptions and ping resulted in this error. After domain restart it works, don't know why.

Play! framework - Cannot connect to database

this is the error I get when I'm trying to connect to my local postgresql db:
Cannot connect to database [default]
this is the database configuration. I'm convinced that there is not typo (fat finger error):
db.default.url="postgres://localhost:5432/myproject/"
db.default.user="postgres"
db.default.pass="mypassword"
db.default.driver="org.postgresql.Driver"
db.default.initSQL="SELECT 1"
where is the problem? with pgAdmin I can connect easily
p.s.
I'm using ubuntu. I've noticed that in order to change to postgres user
I must use "su", otherwise it fails changing the current user.
is that has something to do with play! failure to connect my db?
thanks
There might be two things wrong or at least dubious in your setup.
First: The postgres:... URL syntax is not a plain JDBC URL. This format is not understood by the PostgreSQL JDBC driver. See this answer to a similar problem.
Second: You are trying to use the PostgreSQL superuser account for Play. The superuser account should be used only for administrative work, but not "normal" work. Especially not for work which includes public access to the DB via some webfrontend. Any SQL-Injection attack gives the attacker the golden key to your database - including the nuke to wreck your complete DB cluster at once or install any backdoor into you DB server.
So I recommand, that you create a new user which you configure in your Play! settings.
That said: The default password for the postgres user is not set on Ubuntu. This setup allows login to the DB user only from the same OS user. How you can fix this is explained in this answer.
If these two tips don't help: The error you quoted is very vague. There must be more detailed error logs somewhere. Please find them and attach them to your question with the "edit" button.
This is not an answer directly to your question, but I had the same error message and came here via Google. Using Scala Play 2.3, I had
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://127.0.0.1:5432/noob_development"
db.default.logStatements=true
which needed to be
db.default.driver="org.postgresql.Driver"
db.default.url="jdbc:postgresql://127.0.0.1:5432/noob_development"
db.default.logStatements=true
I accidentally left the quotes around the driver name out. Now it works perfectly.
here is my conf, it works:
db.default.url="jdbc:postgresql://127.0.0.1:5432/dbname"
db.default.driver="org.postgresql.Driver"
just add the jdbc: before postgresql in db.default.url.

Oracle ODI / Java - Active Directory connection trouble

I want Oracle Data Integrator 10.1.3 to be able to connect to Active Directory running on a Windows 2003.
I'm using SnpsLdapDriver but so far I'm dead unable to make it work.
I keep getting error 52e : Insufficient Credentials. I tried every possible possible way I could - locking my account numerous times- and just nothing but errors.
jdbc:snps:ldap?ldap_url=ldap://128.1.1.121:389/DC=mydc,DC=int??base?(objectClass=*)&ldap_password='encrypted_password_through_snpsldapo.jar'
I tried everything I could find on google....
HELP ????
TIA
52e is the LDAP error code indicating either an invalid user principal or invalid user password.

Categories

Resources