1

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

i changed, now it gives this error: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
@AliyuHeidarUmar, are you sure that database is up and running and that port in URL is correct? And that port 1433 is not blocked by firewall?
Yes, The database is on the local machine, and i don`t have any firewall on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.