java.sql.SQLException: No suitable driver found for jdbc:mi
程序员文章站
2022-04-24 22:02:40
...
环境:SQLServer 2008 R2 MyEclipse 6.5 JDK 1.6.24 问题:Java通过JDBC连接SQLServer 2008,出现如下问题:ava.sql.SQLException: No suitable driver found forjdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=QQ。 解决:检查连接数据库时写的代
环境:SQLServer 2008 R2 + MyEclipse 6.5 + JDK 1.6.24
问题:Java通过JDBC连接SQLServer 2008,出现如下问题:ava.sql.SQLException: No suitable driver found forjdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=QQ。
解决:检查连接数据库时写的代码是否有问题。
代码如下:
package com.qq.client.db; import java.sql.Connection; import java.sql.DriverManager; /** * 连接数据库的类 * @since 1.0 * @author Wentasy * */ public class ConnDB { private Connection conn = null; public Connection getConn(){ try { //注意这串字符串的顺序,不同的数据库版本这行不同。 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=QQ","sa","sa"); //注:连接SQLServer 2008 没有microsoft,把这个去掉问题解决。 conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=QQ","sa","sa"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return conn; } }
参考资料:
http://*.com/questions/5616898/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmicrosoftsqlserver
附JDBC连接SQLServer 2008驱动下载,请点击这里。
推荐阅读
-
Mybatis 报错java.sql.SQLException: No suitable driver found for http://www.example.com
-
Tomcat启动报错 No suitable driver found for jdbc:mysql://localhost:3306……
-
java.sql.SQLException: No suitable driver found for jdbc:mys_MySQL
-
解决jdbc远程连接db2的报no suitable driver问题
-
解决jdbc远程连接db2的报no suitable driver问题
-
SSH2+proxool 出现No suitable driver found for proxool.mysqlP
-
java.sql.SQLException: No suitable driver found for jdbc:mi
-
SSH2+proxool 出现No suitable driver found for proxool.mysqlP
-
java.sql.SQLException: No suitable driver found for jdbc:mi
-
Mybatis 报错java.sql.SQLException: No suitable driver found for http://www.example.com