Hibernate3与SQL连接时出现的java.lang.AbstractMethodError: com.......

本文介绍了解决Hibernate连接SqlServer2000时出现特定错误的方法。通过更换微软官方驱动为jtds驱动,成功解决了AbstractMethodError的问题。

今儿我配置了ssh框架,当用hibernate连接SqlServer2000的时候出现了下面的错误,弄得很是难受,不过还是找到了解决的办法,再次贴出,以备不时之需,呵呵!

报错信息:

java.lang.AbstractMethodError:com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z

或者

java.lang.AbstractMethodError: com.microsoft.jdbc.base.BaseDatabaseMetaData.getJDBCMajorVersion()I

错误原因:

网上查找资料发现原因是microsoft(微软)提供的SqlServer数据库驱动存在bug。(注意:java代码调原驱动连接数据库是没有问题的,搭配hibernate会有此问题。) 需要换一种驱动连接,使用jtds这种驱动,就可以了。

解决方法:

在浏览器中输入下载地址:http://sourceforge.net/projects/jtds/files/,下载jtds1.2版(大概500多K),解压得到jtds-1.2.jar,引用到eclipse中项目目录下(去除原驱动引用),更改hibernate配置文件:

原驱动连接配置:

<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
        <property name="connection.url">jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=hibernate</property>
更改jtds连接:  
        <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
        <property name="connection.url">jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=hibernate</property>

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;chargingSystemController&#39;: Unsatisfied dependency expressed through field &#39;chargingSystemService&#39;; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;chargingSystemServiceImpl&#39;: Unsatisfied dependency expressed through field &#39;tokenUtilMapper&#39;; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;tokenUtilMapper&#39; defined in file [D:\项目\cmms-sv\target\classes\com\rd\cmms\chargingSystem\mapper\TokenUtilMapper.class]: Unsatisfied dependency expressed through bean property &#39;sqlSessionFactory&#39;; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;sqlSessionFactory&#39; defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method &#39;sqlSessionFactory&#39; parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;createDataSource&#39; defined in class path resource [com/rd/cmms/config/ShardingJdbcConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method &#39;createDataSource&#39; threw exception; nested exception is java.lang.AbstractMethodError: com.mysql.jdbc.JDBC4Connection.getSchema()Ljava/lang/String;
最新发布
08-05
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值