Aliyu Heidar Umar
Aliyu Heidar Umar

Reputation: 53

Connection Java application with SQL Server

I am trying to connect my java application with Microsoft SQL Server DBMS. here is my connection string:

try{
    String host = "jdbc:sqlserver://localhost:1433;databaseName=JITM;integratedSecurity=true";
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerh=Driver");
    con = DriverManager.getConnection(host);
    stmt = con.createStatement();
    System.out.println("Connection Successful");
}catch(SQLException err){
    System.out.println(err.getMessage());
}catch (ClassNotFoundException ex) {
        System.out.println(ex.getMessage());
}

it display this error.

com.microsoft.sqlserver.jdbc.SQLServerh=Driver

i have added sqljdbc41.jar in the libraries. the database is windows authentication.

Upvotes: 1

Views: 333

Answers (1)

Ivan
Ivan

Reputation: 8758

You have a misprint in the name of a driver class. Change that code line to this Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Upvotes: 1

Related Questions