sql server - java.sql.SQLException: No suitable driver found for jdbc:sqlserver... (intellij, maven) -


i have above error , wondering do. have done following things already:

  1. downloading sqljdbc4.jar microsofts website
  2. installing local maven repository
  3. including in pom.xml this:

    com.microsoft.sqlserver sqljdbc4 4.0

since using jdbc4, read not have call class.forname, can build connection database directly. why still nosuitabledriver error?

edit: when using classforname below, classnotfoundexception.

class.forname("com.microsoft.jdbc.sqlserver.sqlserverdriver"); //i tried class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver") string dburl = "jdbc:sqlserver://localhost;databasename=test;integratedsecurity=trues"; conn = drivermanager.getconnection(dburl); 

first need make sure driver classpath correct classpath:

class.forname("com.microsoft.jdbc.sqlserver.sqlserverdriver"); 

changed to:

 class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver"); 

second need make sure dburl correct dburl:

string dburl = "jdbc:sqlserver://localhost;databasename=test;integratedsecurity=trues"; 

change to:

string dburl = "jdbc:sqlserver://localhost:1443;databasename=test;integratedsecurity=trues"; 

third, add db username , password in getconnection method:

conn = drivermanager.getconnection(dburl); 

change to:

conn = drivermanager.getconnection(dburl,"yourusername","yourpass"); 

hope helps.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -