Hello all,
I am trying to connect to a MS Sql Server database using the
jdbc driver provided by MS. When I try to run the program, I get a ClassNotFoundException. Here is the line generating the exception:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
I have added the three .jar files that were installed to the classpath, but still get this error.
I'm sure there is something simple that I am missing, but could someone please give me some advice. Here is the entire code for the problem:
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://myip:1433","uid","pwd");
Statement statement=connection.createStatement();
String query="select * from test.SHIPPING";
ResultSet resultSet = statement.executeQuery(query);
while(resultSet.next())
{
System.out.println("pn="+resultSet.getString(1).toString()+"sn="+resultSet.getString(2));
}
}
catch(Exception e)
{
System.out.println("Error with connection "+e.toString());
}
Please give me any advice thanks
-A