Reputation: 47
Basically I'm trying to connect my eclipse to JDBC, I've already add the external path of jdbcsql to my eclipse.
When I rand my java in code in eclipse, so far I have this error:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=MASTER
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at insertion.insert_values(insertion.java:12)
line 12 revers to this line:
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=MASTER","sa","password");
I uses my SA account for JDBC, and this part of my Java code that connect my eclipse to the JDBC driver:
Connection con = null; PreparedStatement statement = null; //to take care of the sql statements to be run
//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=MASTER","sa","ronpaul");
Is the problem with my URL or my code syntax, or is it I didn't add the external jar to my eclipse the right way?
I already added the last JDBC driver to my java package path, so what's causing the error? The line 12 has a code syntax error maybe?
Upvotes: 0
Views: 2336
Reputation: 123484
Is the problem with my URL
Yes. Microsoft's JDBC Driver for SQL Server uses the URL prefix
jdbc:sqlserver://...
not
jdbc:microsoft:sqlserver://...
See the MSDN document Building the Connection URL for details.
Upvotes: 1