0

I've found this question before but none of the answers work for me!

public static void main(String[] args) throws ClassNotFoundException, SQLException {

        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String 
        connectionURL="jdbc:sqlserve:z/localhost:1433;databaseName=isTaskDB;user=is;password=1234";
        Connection con =DriverManager.getConnection(connectionURL);
        System.out.println("done");
}

I get this error:

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:sqlserve:z/localhost:1433;databaseName=isTaskDB;user=is;password=1234 at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:270) at is_prog_task.Is_prog_task.main(Is_prog_task.java:26) Java Result: 1

why??

Alexander van Oostenrijk
  • 4,644
  • 3
  • 23
  • 37
  • 1
    Have you added a jar with the MS Sql Server Driver to your classpath? If not, you can get more information here https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15 – Pete Kelley Dec 20 '19 at 20:14
  • Also - the connection url reads "...jdbc:sqlserve:z?..." perhaps tha tshould be "...jdbc:sqlserver:z?..." – Pete Kelley Dec 20 '19 at 20:16
  • 3
    Does this answer your question? [java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver](https://stackoverflow.com/questions/5616898/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmicrosoftsqlserver) – Kaan Dec 20 '19 at 20:18

1 Answers1

1

Try replacing

jdbc:sqlserve:z/localhost:1433;databaseName=isTaskDB;user=is;password=1234

with

jdbc:sqlserver://localhost:1433;databaseName=isTaskDB;user=is;password=1234

See MS SQL Server Programming Guide for JDBC SQL Driver for more information.

haba713
  • 2,465
  • 1
  • 24
  • 45