-1

I am trying to parameterize gmail login script, for which I am trying to fetch data from database(sql server), but when I run the code am getting the following error:

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost/hrm

The connection string that I am passing is as follows:

Connection cn=DriverManager.getConnection("jdbc:sqlserver://localhost/hrm","sa","a1");

Please help.

user1766169
  • 1,932
  • 3
  • 22
  • 44
Shruti
  • 51
  • 2
  • 9
  • 1
    Possible duplicate of [How to fix: "No suitable driver found for jdbc:mysql://localhost/dbname" error when using pools?](http://stackoverflow.com/questions/5556664/how-to-fix-no-suitable-driver-found-for-jdbcmysql-localhost-dbname-error-w) – Andy Guibert Jan 09 '16 at 19:53

2 Answers2

1

Was your jdbc driver correctly added to the build path? If that is not the problem you can add Class.forName(yourDriver); in your code

Hope that helps

Mawcel
  • 1,967
  • 15
  • 22
  • `Class.forName()` hasn't been necessary to load JDBC drivers since Java 5. If you are using Java6+ and JDBC 4+ it's not needed. – Andy Guibert Jan 09 '16 at 19:52
0

You may need to add required JDBC Driver or jar.

https://msdn.microsoft.com/en-us/data/aa937724.aspx

If you provided jar in build path, please provide more code to help you.

Thanks

murali selenium
  • 3,847
  • 2
  • 11
  • 20