0

I started working today with the JDBC Microsoft SQL Server driver and I am always getting the error that no suitable driver has been found.

Here is my 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();
        }

I also used Class.forName(...), but since it will be running on other people's servers I don't want to use this option (This option also did not work). Help would be appreciated, have a nice weekend

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lucas Romier
  • 1,291
  • 1
  • 13
  • 22
  • Did you download and install the MS SQL Server JDBC driver? what platform are you running on ? Perhaps try this to test if it is installed: http://stackoverflow.com/questions/4215742/how-to-test-if-jdbc-driver-is-installed-correctly-and-if-the-db-can-be-connected. It's Class.forName but just use it to test for now and isolate the issue – Nick.Mc Mar 05 '16 at 07:50
  • You don't have the driver jar in your path, that's my guess. – TT. Mar 05 '16 at 08:39

0 Answers0