• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC MYSQL  RSS feed

 
nirail rail
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we use following string in jsp/java code to connect to oracle

code
____________________________________________________________
String url = "jdbc :0racle:thin:@127.0.0.1:1521 :0racleSID";
----------------------------------------------------------------

what code/string is used for MySql and which drivers are required for mysql

pls help
[ July 27, 2004: Message edited by: nirail rail ]
 
prem saggar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've done this, and I'm sure I got the complete information from mysql.org. Also, there are a bunch of tutorials out there. Google search = java jdbc mysql driver try. The try will probably garuntee you a code example . Happy hunting. Prem
 
Jonas Isberg
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the one found at:

Unpack the .jar file and make sure it is included in your CLASSPATH.

Load the driver with:
Class.forName("com.mysql.jdbc.Driver").newInstance();
and get a connection with something like:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=");
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for the record, you only need to put .instance() if you're using Java 1.1 or earlier, otherwise Class.forName(...) will be enough.

Only a small point and hardly worth mentioning, but sometimes its nice to know. It could save you from creating one whole instance

Dave
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!