File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes can't get access to mysql database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "can Watch "can New topic
Author

can't get access to mysql database

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi Guys,

I'm working on a web app involving database connectivity to MySQL. My context.xml file looks like so:

<Context path="/BannerAd2" docBase="BannerAd2" debug="0"
reloadable="true" crossContext="true">

<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_bannerad_log." suffix=".txt"
pattern="common"/>


<Resource name="jdbc/banneraddb" auth="Container" type="javax.sql.DataSource"
username="webapp" password="secret" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/banneraddb?autoReconnect=true"
maxActive="10" maxIdle="3" maxWait="10000"/>

</Context>

I've used the following GRANT commands to allow access to the database:

grant select,insert,update,delete on banneraddb.* to 'webapp'@'%' identified by 'secret';
flush privileges;

I had no problem executing these two commands. According to documentation for MySQL the "%" symbol is supposed to allow access from any location. Of course the database is on my localhost workstation, so why do I still get the following error message at the command prompt?

Caused by: java.sql.SQLException: Access denied for user 'webapp'@'localhost' (u
sing password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:934)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4104)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1299)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:
2186)
... 45 more

Please advise,

Alan
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 175
    
    1

Check that the password is correct..


Ramesh-X
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't get access to mysql database