I have created this simple test to see if I can connect to my local SQL Server 2014 Express Database:
import java.sql.*;
public class SQLServercheck{
public static void main (String[] args){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection
("jdbc:sqlserver://mypc\\SQLEXPRESS:mydatabase");
System.out.println("Connection Successful");
} catch (SQLException sqle){
System.out.println("SQL Error: " + sqle);
} catch (ClassNotFoundException cnfe){
System.out.println("Class not found exception: " + cnfe);
}
} }
When running it, I get the following message:
run:
Class not found exception: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver BUILD SUCCESSFUL (total time: 0 seconds)
I am a student so please answer with some explanation if possible. Much appreciated.