hi the code below is supposed to establish a connection to my database
located on a sql-server. but there is always thr following exception:
java.sql.SQLException: No suitable driver
i have downloaded the driver from microsoft
(http://www.microsoft.com/downloads/details.aspx?FamilyID=86212d54-8488-481d-b46b
-af29bb18e1e5&DisplayLang=en)
and copied the 3 jar-files to C:\Program Files\
j2sdk1.4.2_04\jre\lib\ext and C:\Program Files\Java\
j2re1.4.2_04\lib\ext.
any ideas what i'm doing wrong?
public void testCON(){
Connection connection = null;
try {
String driverName =
("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Class.forName(driverName);
String serverName = "lt51s";
String mydatabase = "ADMS";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
String username = "user";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
}catch (ClassNotFoundException e) {
System.out.println(e);
}catch (SQLException e) {
System.out.println(e);
}
}
Manfred Rosenboom - 22 Jul 2004 12:23 GMT
> String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
Your JDBC URL is wrong!
Try the following one:
String url = "jdbc:microsoft:sqlserver://" + serverName + ";databaseName=mydatabase"
Best,
Manfred