-----Original Message-----
From: Scott D. Spiegler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 25, 2004 11:37 AM
To: [EMAIL PROTECTED]
Subject: Unable to Programatically Create DB Connection
> I am trying to programatically connect to my DB, but I am not sure
what
> the connection string should be. I am using this statement:
>
> conn =
>
DriverManager.getConnection("jdbc:mysql://localhost/test?user=scott&pass
word=cuatro");
>
> I am getting this exception message:
>
> database_test.DBConnector
> SQLException: No suitable driver
>
> SQLState: 08001
>
> VendorError: 0
>
> Any idea as to what the correct, connection string might be?
>
> Thanks, Scott
Did you load the driver with Class.forName?
Here is an example:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
// Notice, do not import com.mysql.jdbc.*
// or you will have problems!
public class LoadDriver {
public static void main(String[] args) {
try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
}
This is all in the ConnectorJ docs at:
http://dev.mysql.com/doc/connector/j/en/#id2801034
Jim Drabb
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-
He who receives an idea from me, receives instruction himself without
lessening mine; as he who lights his taper at mine, receives light
without
darkening me. -- Thomas Jefferson; 1813
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-
James Drabb JR
Senior Programmer Analyst
Darden Restaurants
Business Systems
JDrabb at Darden dot com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]