File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "can Watch "can New topic

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"

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


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(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.secureAuth411(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.ConnectionImpl.coreConnect(
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(
... 45 more

Please advise,

Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 178

Check that the password is correct..

I agree. Here's the link:
subject: can't get access to mysql database
It's not a secret anymore!