JDBC/mySQL Question


I am trying to get java apps to be able to talk to mySQL on my OS X.1 box. I have downloaded the most recent version of mm.mysql drivers and have followed the instructions for installing them (in /usr/local/tomcat/lib). I have phpMyAdmin running and it is able to connect to the mysql db system just fine. However when I try to open a connection:

static String ConnectURL =

try {
Connection conn = DriverManager.getConnection(ConnectURL);
catch (SQLException e) {
System.err.println("Driver can't get a connection!");
System.err.println("SQLExecption: " + e.getMessage());
System.err.println("SQLState: " + e.getSQLState());
System.err.println("VendorError: " + e.getErrorCode());
System.out.println("We have a connection!");


I get an error:

Driver can't get a connection!
java.sql.SQLException: Server configuration denies access to data source
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:193)
at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:199)
at jdbcTest.main(jdbcTest.java:35)
SQLExecption: Server configuration denies access to data source
SQLState: 08001
VendorError: 0

I can load the driver just fine with this code:

try {
catch (Exception e) {
System.err.println("Unable to load driver.");
System.out.println("Driver loaded okay!");

Any ideas why I am getting a Server configuration denies access to data source when the password that I am using in the java connection url is the same that I am using inside of phpMyAdmin's config?

Thanks for your help!

After a long search through google.com I was able to find the answer to my question. I needed to have a mysql user which which wasn't tied to localhost. So I added another root user with host = % (for any host) and then ran my java program and it worked perfectly. Just make sure you also grant the new user you create premissions to the appropriate dbs inside mysql using the GRANT command.