PDA

View Full Version : Java to MySQL


v4honda
06-29-2006, 05:00 AM
Rather than having to log in to the cpanel and then in to phpmyadmin to do simple database mods I wish to develop a Java application to allow me to connect remotely to my mysql databse and then i can do all the database mods remotely.

Problem is the database server wont allow me to connect from my Java application.

The url connection string I am using in Java is;

"jdbc:mysql:"+HOST+PORT+DBASE+"?user="+USER+"?password="+PASSWORD;

where;

HOST = websitename.com
PORT = 3306
DBASE = cpanelusername_phpbbforum
PASSWORD = xxxxxxxxx

The stacktrace of the error message is as follows;

java.sql.SQLException: Invalid authorization specification, message from server: "Access denied for user 'xxxxx_yyyy?pas'@'dyn-62-56-62-42.dslaccess.co.uk' (using password: NO)"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:1977)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:1900)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java: 2471)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:81 3)
at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1771)
at com.mysql.jdbc.Connection.<init>(Connection.java:440)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:400)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:193)
at jdbcPackages.ConnectionJDBC.makeConnection(Connect ionJDBC.java:46)
at Localdemo.main(Localdemo.java:40)


The same Java code works perfectly to the mysql database running locally on my localhost.

Also the above username password etc WILL connect when using mysql administrator.

Any ideas guys/gals?

I'm wondering is it because it doesnt appear to be using my password?

And yes I have created the relevant user and added that user to the relevant database and granted the required priveleges.

v4honda
06-29-2006, 09:44 AM
Managed to get it sorted.