views:

30

answers:

2

I am new to JSP and I am trying to make a connection to a mysql database. I am using Connect/j driver but I cant find the connection string for my Class.forName() method.

Please give me suggestions

A: 

Assuming your driver is in path,

String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (url, "username", "password");
Langali
A: 

Have you read the documentation?

http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

A basic connection string looks like:

jdbc:mysql://localhost:3306/dbname

The class.forName string is "com.mysql.jdbc.Driver", which you can find here:

http://dev.mysql.com/doc/refman/5.0/es/connector-j-usagenotes-basic.html

Tim Sylvester