繁体   English   中英

java.sql.SQLException:找不到适用于jdbc:microsoft的驱动程序

[英]java.sql.SQLException: No suitable driver found for jdbc:microsoft

您好,我需要将Java程序连接到Microsoft Sql服务器。 我得到java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://LB236:1521;databasename=checkpointDB我找不到任何问题,请看一下我的代码并告诉我怎么了。

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+ properties.getProperty(CP.dbHost.toString())+":"+properties.getProperty(CP.dbPort.toString())+";databasename="+properties.getProperty(CP.dbDatabase.toString()),properties.getProperty(CP.dbUser.toString()),AppDecrypter.getInstance().decrypt(properties.getProperty(CP.dbPassword.toString())));

全栈跟踪:

java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://LB236:1521;databasename=checkpointDB
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at de.mvn.gotdb_mvn.Importer.openConnection(Importer.java:117)
at de.mvn.gotdb_mvn.Importer.openConnection(Importer.java:135)
at de.mvn.gotdb_mvn.Main.main(Main.java:33)

我认为问题出在您输入的JDBC网址上。

它应该是jdbc:sqlserver:// ServerName \\ sqlexpress .....

确保您正在使用的sqljdbc jar文件包含在项目的构建路径中。

这是 SQL Server 的好教程

连接网址应如下所示:

DriverManager.getConnection("jdbc:sqlserver://"+.......

忽略连接字符串中的“:microsoft”。

希望这行得通。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM