【发布时间】:2017-03-22 00:41:38
【问题描述】:
基本上我正在尝试将我的eclipse连接到JDBC,我已经将jdbcsql的外部路径添加到我的eclipse中。
当我在 Eclipse 的代码中运行我的 java 时,到目前为止我有这个错误:
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");
我将我的 SA 帐户用于 JDBC,以及将我的 eclipse 连接到 JDBC 驱动程序的这部分 Java 代码:
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 中?
我已经将最后一个 JDBC 驱动程序添加到我的 java 包路径中,那么导致错误的原因是什么?第12行可能有代码语法错误?
【问题讨论】:
-
你认为
No suitable driver found for jdbc:microsoft:sqlserver是什么意思? -
@ScaryWombat 对不起先生,我才刚刚开始,你能写一个答案告诉我如何解决它吗?
-
只需搜索 jdbc sqlserver 驱动程序(google 是你的朋友)并将其添加到你的类路径
-
看看Building the Connection URL。 URL 前缀必须是
jdbc:sqlserver://...,而不是jdbc:microsoft:sqlserver://...。 -
@gord thompson 嘿,先生,谢谢!我固定你能写一个答案,所以我会接受它。随便写点什么,我保证我会接受的
标签: java sql-server eclipse jdbc runtime-error