org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection异常问题解决;

spring boot ,mybatis ,sqlserver 2000,STS3.9 、jdk8 ,sqljdbc4 1.0-2000的一个环境启动时,调用查询Dao时报错。

具体错误如下:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:microsoft:sqlserver://10.249.0.129:1433;DatabaseName=YZYB'
### The error may exist in file [D:\STS-CODE\yzyb\target\classes\mapper\SupplierMapper.xml]
### The error may involve com.cn.lbx.dao.SupplierDao.getSuppliers
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:microsoft:sqlserver://10.249.0.129:1433;DatabaseName=YZYB'
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) ~[mybatis-spring-1.3.1.jar:1.3.1]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-1.3.1.jar:1.3.1]
   

数据源配制:

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection_第1张图片

经过查询百度上是如下说法:

连接SqlServer2000 
 
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 
URL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb"; 
 
连接SqlServer2005 
 
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
URL = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb"; 

而我自己的正好是sqlserver2000,经过上一篇文章中处理的问题,干脆所有配制都改成sqlserver2005版本形式。

修改后如下图:

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection_第2张图片

修改后系统就能正常进行增、删、查、改了!!!。怀疑是跟我用的驱动与系统环境比较新有关吧!!

你可能感兴趣的:(经验分享)