|
Connecting To SQL Server
Here is the code that I have written to get a connection to the SQL Server. I have also set the classpath. But still I am getting error. I have debugged the code and when I step over the Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver"); it generates an exception and the message that is printed is the string that is the parameter to the function forName. I am struck as I have searched a lot of forums and I haven't found this kind of error. Most of the errors that came due to classpath settings was "drievr cannot be found" but I think my error is not because of the classpath settings. Can anyone help me?
public class Main {
public static void main(String[] args) {
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://localhost:1433; DATABASENAME = Test","mimdad","aaa");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
|