Java 获得;找不到适合的驱动程序……”;JDBC错误,但我已经将jar添加到我的Eclipse路径中
基本上,我正在尝试将eclipse连接到JDBC,我已经将jdbcsql的外部路径添加到eclipse中 当我在eclipse中对java代码进行rand时,到目前为止,我遇到了以下错误:Java 获得;找不到适合的驱动程序……”;JDBC错误,但我已经将jar添加到我的Eclipse路径中,java,sql-server,eclipse,jdbc,runtime-error,Java,Sql Server,Eclipse,Jdbc,Runtime Error,基本上,我正在尝试将eclipse连接到JDBC,我已经将jdbcsql的外部路径添加到eclipse中 当我在eclipse中对java代码进行rand时,到目前为止,我遇到了以下错误: Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=MASTER at java.sql.Dri
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)
第12行与本行相反:
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=MASTER","sa","password");
我使用JDBC的SA帐户,这部分Java代码将eclipse连接到JDBC驱动程序:
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");
是我的URL或代码语法有问题,还是我没有以正确的方式将外部jar添加到eclipse中
我已经在java包路径中添加了最后一个JDBC驱动程序,那么是什么导致了错误呢?第12行可能有代码语法错误
我的URL有问题吗
对。Microsoft的SQL Server JDBC驱动程序使用URL前缀
jdbc:sqlserver://...
不是
jdbc:microsoft:sqlserver://...
有关详细信息,请参阅MSDN文档。您认为
没有找到适合jdbc的驱动程序是什么意思?@ScaryWombat抱歉,先生,我才刚刚开始,您能写一个答案告诉我如何修复它吗?只需搜索jdbc sqlserver驱动程序(谷歌是您的朋友)并将其添加到您的classpath中即可查看。URL前缀必须是jdbc:sqlserver://...
,而不是jdbc:microsoft:sqlserver://...
@gord thompson嘿,先生,谢谢!我能给你写个答案,所以我会接受的。只要写任何东西,我保证我会接受