java连sql server 问题 java.lang.AbstractMethodError: com.microsoft.jdbc.base.BaseDatabaseMetaData.getJ

时间:2022-05-01 00:40:46
Caused by: java.lang.AbstractMethodError: com.microsoft.jdbc.base.BaseDatabaseMetaData.getJDBCMajorVersion()I
at org.hibernate.engine.jdbc.JdbcSupportLoader.useContextualLobCreation(JdbcSupportLoader.java:78)
at org.hibernate.engine.jdbc.JdbcSupportLoader.loadJdbcSupport(JdbcSupportLoader.java:52)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:121)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)

使用java 连 sql server 报以上错误,原因是微软 自带的jar包 bug 问题,正常是可以的,所以要换成jtds-1.3.1.jar

将配置文件中的url 改成 jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=你的数据库名

驱动改成net.sourceforge.jtds.jdbc.Driver

就可以了