baidu_29075865
baidu_29075865
采纳率0%
2015-06-16 08:28 阅读 56.2k

Could not get JDBC Connection

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

The error may exist in cn/drzk/wanda/cinema/dao/form/dao/TicketsFromDao.java (best guess)

The error may involve cn.drzk.wanda.cinema.dao.form.dao.TicketsFromDao.count

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • syjgreen07 不服输的人 2015-06-17 08:35

    找不到这个类,你都不知道怎么做?我去,别再来问了.

    点赞 4 评论 复制链接分享
  • francislpx SimbaLi123 2015-06-16 09:19

    有没有引入SqlServer相关jar包 好像是sqljdbc.jar

    点赞 3 评论 复制链接分享
  • syjgreen07 不服输的人 2015-06-16 09:23

    Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

    明显找不到这个类啊,我去,1楼的人是怎么玩的?

    点赞 2 评论 复制链接分享
  • bdmh bdmh 2015-06-16 08:32

    连接数据库失败,看看配置文件中的数据库名,用户名密码对不对

    点赞 评论 复制链接分享
  • francislpx SimbaLi123 2015-06-16 08:50

    刚才你不是发过贴了···
    Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
    SqlServer的驱动找不到

    点赞 评论 复制链接分享
  • francislpx SimbaLi123 2015-06-16 09:00

    这是一个配置文件模板,就是第二行,要配置数据库JDBC包路径,你找一下是不是这里的问题

    <generatorConfiguration>
    <classPathEntry location="数据库JDBC包路径"/>
    <context id="项目id" targetRuntime="MyBatis3">
    <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"/>
    <plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
    <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin"/>
    <commentGenerator>
    <property name="suppressAllComments" value="true"/>
    </commentGenerator>
    <jdbcConnection driverClass="数据库驱动" connectionURL="数据库URL" userId="数据库用户名" password="密码"/>
    <javaTypeResolver>
    <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>
    <javaModelGenerator targetPackage="目标包名" targetProject="目标路径">
    <property name="enableSubPackages" value="false"/>
    <property name="trimStrings" value="true"/>
    </javaModelGenerator>
    <sqlMapGenerator targetPackage="目标包名" targetProject="目标路径">
    <property name="enableSubPackages" value="false"/>
    </sqlMapGenerator>
    <javaClientGenerator type="XMLMAPPER" targetPackage="目标包名" targetProject="目标路径">
    <property name="enableSubPackages" value="false"/>
    </javaClientGenerator>
    <table tableName="表名" domainObjectName="Model类名"/>
    </context>
    </generatorConfiguration>
    
    
    点赞 评论 复制链接分享
  • baidu_29075865 baidu_29075865 2015-06-16 09:02

    图片说明
    代码就只是测试一下查询
    测试类
    @Autowired
    private TicketsFromDao ticketsFromDao;
    @Test
    public void test6() {
    System.out.println("business.decideTickets()===" + ticketsFromDao.count());
    }

    TicketsFromDao类
    @Repository
    

    public interface TicketsFromDao extends BaseFromDao {

    @Select("exec sys.sp_readerrorlog 0, 1, 'listening'")
    public long count() ;
    
    @Select("select count(1) from Tickets")
    public long countByCondition(Map<String, Object> prame) ;
    
    @Select("select * from Tickets a where a.scanContent=#{scanContent}")
    public List<Tickets> find(Map<String, Object> prame) ;
    
    @Select("select * from Tickets a where a.scanContent=#{scanContent}")
    public List<Tickets> findByDate(Map<String, String> prame) ;
    

    }

    点赞 评论 复制链接分享

相关推荐