public static void getConnection(){
String driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver";
//jdbc:microsoft:sqlserver://host:port;databasename=name;user=yourUser;password=yourPwd
String conURL="jdbc:microsoft:sqlserver://localhost:1433;databasename=Questions";
String userName="sa";
String password="vickey";
Connection con=null;
try{
Class.forName(driverName);
}
catch(Exception e){
System.out.println("Driver Loading problem");
System.out.println(e);
}
try{
con=DriverManager.getConnection(conURL,userName,password);
}
catch(Exception e){
System.out.println("Connection problem");
System.out.println(e);
}
}
This is the code i am using to create connection.
i have put SQL Driver.tar in classpath.
But my program is showing following error:
Driver Loading problem
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
Connection problem
java.sql.SQLException: No suitable driver found for
jdbc:microsoft:sqlserver://localhost:1433;databasename=Questions