Two Laptop Bag*
The moose likes JDBC and the fly likes Reg JDBC Connector in MySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Reg JDBC Connector in MySql" Watch "Reg JDBC Connector in MySql" New topic
Author

Reg JDBC Connector in MySql

Karthik Krishnamurthy
Ranch Hand

Joined: Feb 04, 2005
Posts: 118
Hi,
I am using the mysql-connector-java-3.1.12-bin.jar driver for jdbc connectivity to my MySql Database.

My question is does this need JDK1.4 and above to funtion / deliver a connection.

Reason I am asking is I am working on a company product that uses its own jre (version 1.3) and at the DriverManager.getConnection point it hangs.

Code :
Class.forName("com.mysql.jdbc.Driver");
S.o.pln("After class");
DriverManager.getConnection("jdbc:mysql://localhost:3306/pct","un","pwd");
S.o.pln("After connect");

When I run this one as its own application, the connection is fine.

But when I run it as part of this product it prints "After Class" but stops and does nothing afterward.

Please Help

Thx
KArthik
George Stoianov
Ranch Hand

Joined: Jan 15, 2006
Posts: 94
Hi,

You should get an exception if there is a problem if there is no problem than it maybe that this is taking very long...is the db server on the same machine...seems like it from the url. You can try exchanging localhost with 127.0.0.1 and trying that I had an experience like that with an older driver as far as I can remember. I think your driver is not the latest I think 15 is the latest. Check MySQL.com that would be the best place for the JVM version question as well, even though I think it should work.

You should also try a "dry test" no java just calling up mysql and connection with the same credentials, also check if mysql is running and listening.

Hope this helps
george
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Please please please do not use SMS in your CODE examples! It's just terrible. Javaranch is not charging you the use of this forum by the letter and it makes your code difficult to read.

Now as to your problem. What do you mean hang? Forever? Or just awhile? There are alot of possibilities of what could be happening many of the network related difficulties.

It would be nice to see your real code because for various and sundry reasons what you posted is not it. It would also be nice to see an error message... or perhaps you are eating it in an empty catch block. Please post your actual real code and any error messages you are getting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reg JDBC Connector in MySql