Can not connect to Mysql using jdbc on xp
Posted by: Naomi Blythe
Date: May 30, 2005 09:26PM

I have a java application that links to a mysql database using jdbc, and when I run it on my computer which runs windows 2000, and it works fine. When I set up a mysql database on another computer which runs Windows XP, I get one of two errors:

I originally had the code:

***************************
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
cnn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/prayerdiary:3306?user=root&password=root");
}catch (Exception e) {e.printStackTrace();}
***************************

and was getting the message:

***************************
java.sql.SQLException: Syntax error or access violation, message from server:
"Unknown database 'prayerdiary'
...
***************************

I was told to change the "cnn = ..." line of code to:

***************************
cnn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/prayerdiary?user=root&password=root");
***************************

instead, but then I started getting:

***************************
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
...
***************************

Both versions work on my computer (windows 2000)

I can load and edit the database using mysql command centre, SQLYOG and similar mysql database admin applications so I know the database exists and can be accessed. Just not via my java application.

Have I missed something in the xp installation process, or any other suggestions?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.