spring配置sqlserver2000,出现java.sql.SQLWarning

项目中应用到spring配置sqlserver2000,用com.mchange.v2.c3p0.ComboPooledDataSource来做连接池,具体配置如下:

<bean id="misDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<property name="jdbcUrl" value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=fook"/>
<property name="user" value="sa"/>
<property name="password" value="sa"/>
<property name="minPoolSize" value="10" />
<property name="maxPoolSize" value="30" />
<property name="idleConnectionTestPeriod" value="1800" />
<property name="acquireIncrement" value="5" />
<property name="maxIdleTime" value="3600" />
<property name="maxIdleTimeExcessConnections" value="600" />
<property name="initialPoolSize" value="2" />
<property name="checkoutTimeout" value="5000" />
</bean>

结果在程序中得到连接后报如下信息(各种包已经正确导入):

java.lang.AbstractMethodError
at com.mchange.v2.c3p0.impl.NewPooledConnection.carefulCheckHoldability(NewPooledConnection.java:117)
at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:109)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:198)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
[DateTime] 2010/12/31/ 17:26:26 [PRIORITY] INFO [MDC]
[THREAD] com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1 [CATEGORY] com.mchange.v2.c3p0.SQLWarnings
[MESSAGE] [Microsoft][SQLServer JDBC Driver]Database changed to fook

java.sql.SQLWarning: [Microsoft][SQLServer JDBC Driver]Database changed to fook
at com.microsoft.jdbc.base.BaseWarnings.add(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processEnvChange(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
java.sql.SQLWarning: [Microsoft][SQLServer JDBC Driver]Language changed to us_english
at com.microsoft.jdbc.base.BaseWarnings.add(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processEnvChange(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

应该如何解决?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLCA是一个结构体,包含了SQL语句执行后的返回信息。在Java中,如果要使用SQLCA,需要使用JDBC连接数据库,然后执行SQL语句,将返回的信息存储到SQLCA结构体中。 具体步骤如下: 1. 加载JDBC驱动程序。 2. 建立数据库连接。 3. 创建Statement对象,用于执行SQL语句。 4. 执行SQL语句,将返回信息存储到SQLCA结构体中。 5. 根据SQLCA中的返回信息,处理相应的业务逻辑。 下面是一个示例代码: ``` import java.sql.*; public class SQLCAExample { public static void main(String[] args) { String url = "jdbc:mysql://localhost:3306/testdb"; String username = "root"; String password = "root"; Connection conn = null; Statement stmt = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); String sql = "SELECT * FROM users"; boolean result = stmt.execute(sql); if (result) { ResultSet rs = stmt.getResultSet(); while (rs.next()) { // do something with the result set } rs.close(); } else { int updateCount = stmt.getUpdateCount(); if (updateCount == -1) { // no more results } else { // update count } } SQLWarning warning = stmt.getWarnings(); while (warning != null) { // process warning warning = warning.getNextWarning(); } SQLCA sqlca = ((com.mysql.jdbc.StatementImpl) stmt).getSQLCA(); if (sqlca != null) { // process sqlca } } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值