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:
- downloading sqljdbc4.jar microsofts website
- installing local maven repository
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
Post a Comment