jdbcTemplate与c3p0挂起

时间:2013-02-18 08:31:11

标签: c3p0 jdbctemplate apache-commons-dbcp

我有一个非常简单的测试,它适用于dbcp连接池,并且永远与c3p0(0.9.2)挂起。

    private String query="select ROWID from SOMETABLE "  +
            " where  rownum <= 100 for update skip locked";
private String deleteQuery = "delete from SOMETABLE where ROWID = ?";

public void retrieve() throws Exception {
    while (retrieveChunk() > 0){
        //do nothing
    }
}

@Transactional
private int retrieveChunk(){

    final List<Object[]> delPar = new ArrayList<Object[]>(100);
    template.query(query, new RowCallbackHandler() {
        public void processRow(ResultSet rs) throws SQLException {
            String rowid = rs.getString(1);
            delPar.add(new String[]{rowid});
        }
    });
    template.batchUpdate(deleteQuery, delPar);
    return delPar.size();
}

春天背景:

    <bean id="connPool" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close">
    <property name="user" value="**"/>
    <property name="password" value="**"/>
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@****"/>
    <property name="initialPoolSize" value="0"/>
    <property name="maxPoolSize" value="10"/>
    <property name="minPoolSize" value="1"/>
    <property name="acquireIncrement" value="1"/>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg>
        <ref bean="connPool"/>
    </constructor-arg>
</bean>

c3p0配置有什么问题?

更新 - log4j输出:

12:17:18,449 DEBUG JdbcTemplate:435 - Executing SQL query [select ROWID from SOMETABLE  where  rownum <= 100 for update skip locked]   

12:17:18,465 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,809 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,809 DEBUG JdbcTemplate:881 - 执行SQL批量更新[从SOMETABLE删除ROWID =?] 12:17:18,824 DEBUG JdbcTemplate:570 - 执行准备好的SQL语句[从SOMETABLE中删除ROWID =?] 12:17:18,824 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,887 DEBUG JdbcUtils:362 - JDBC驱动程序支持批量更新
12:17:18,902 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,902 INFO PlainJdbcTableRetriever:36 - JdbcTemplateRetriever检索开始
12:17:18,902 DEBUG JdbcTemplate:435 - 执行SQL查询[从SOMETABLE中选择ROWID,其中rownum&lt; = 100表示​​更新已跳过锁定]
12:17:18,902 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,934 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,934 DEBUG JdbcTemplate:881 - 执行SQL批量更新[从SOMETABLE删除ROWID =?] 12:17:18,934 DEBUG JdbcTemplate:570 - 执行准备好的SQL语句[从SOMETABLE中删除ROWID =?] 12:17:18,934 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,934 DEBUG JdbcUtils:362 - JDBC驱动程序支持批量更新
12:17:18,934 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,934 DEBUG JdbcTemplate:435 - 执行SQL查询[从SOMETABLE中选择ROWID,其中rownum&lt; = 100表示​​更新已跳过锁定]
12:17:18,934 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,981 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,981 DEBUG JdbcTemplate:881 - 执行SQL批量更新[从SOMETABLE删除ROWID =?] 12:17:18,981 DEBUG JdbcTemplate:570 - 执行准备好的SQL语句[从SOMETABLE中删除ROWID =?] 12:17:18,981 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:18,981 DEBUG JdbcUtils:362 - JDBC驱动程序支持批量更新
12:17:18,996 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:18,996 DEBUG JdbcTemplate:435 - 执行SQL查询[从SOMETABLE中选择ROWID,其中rownum&lt; = 100表示​​更新已跳过锁定]
12:17:18,996 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:19,012 DEBUG DataSourceUtils:327 - 将JDBC连接返回到DataSource
12:17:19,012 DEBUG JdbcTemplate:881 - 执行SQL批量更新[从SOMETABLE删除ROWID =?] 12:17:19,012 DEBUG JdbcTemplate:570 - 执行准备好的SQL语句[从SOMETABLE中删除ROWID =?] 12:17:19,012 DEBUG DataSourceUtils:110 - 从DataSource获取JDBC连接
12:17:19,012 DEBUG JdbcUtils:362 - JDBC驱动程序支持批量更新

0 个答案:

没有答案