Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Connector/J

Status
Not open for further replies.

new2this2002

Programmer
Jun 22, 2002
67
GB
I am trying to get java to communicate with my mysql server but i am having problems with the latest version of the mysql jdbc driver connector/j 3.1.0-alpha. Here is my setup

I am using win2k pro, j2sdk1.4.2 and mysql 4.1. My mysql database has the following databases...
mysql
test
testdb

if i run the following java code.....

Class.forName(com.mysql.jdbc.Driver).newInstance();
String dbURL = "jdbc:mysql://localhost:3306/testdb";
java.sql.Connection conn = DriverManager.getConnection(dbURL,"root","rootPassword");
System.out.println("Connected");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Employees");
conn.close();
System.out.println("Closed");

I get an error saying that the table employees does not exist in the table 'test'. This is correct but the database i specified to connect to was 'testdb'. So for some reason the database name specified as part of the jdbc url is being truncated.

If i try the same code using connector/j 3.0.8-stable i get no errors. The same problem occurs when specifying the 'mysql' database.

Does anyone have any thoughts as to why this may be happening.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top