1

I am totally new to MS SQL and I am stuck on some errors.

I included the sqljdbc42.jar as an external file in eclipse and I have the following lines of code:

        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        String url = "jdbc:sqlserver://" + HOST + ":" + PORT + ";databaseName=" + DATABASE;
        try {
            connection = DriverManager.getConnection(url, USERNAME, PASSWORD);
        } catch (SQLException e) {
            System.err.println("[SQL] Error in connection: " + url);
            e.printStackTrace();
        }

Whenever i run this code, I encounter the following errors:

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

and

java.sql.SQLException: No suitable driver found for jdbc:sqlserver://sql3.freemysqlhosting.net:3306;databaseName=sql3109409

I set the eclipse export settings to export generated files and also external resources. Could anyone please help me fix this error?

Hava a nice weekend, Lucas Romier

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Lucas Romier
  • 1,291
  • 1
  • 13
  • 22
  • Isn't this question the same as you posted yesterday [here](https://stackoverflow.com/questions/35810209/microsoft-sql-server-no-suitable-driver)? – TT. Mar 06 '16 at 09:18

0 Answers0