#13 InterruptedException thrown when executings many statements

open
nobody
None
5
2005-05-19
2005-05-19
Anonymous
No

Following exception is thrown when I try to execute
many statements.
-------------------------------------------

java.sql.SQLException: An SQLException was provoked
by the following failure: java.lang.InterruptedException
at
com.mchange.v2.sql.SqlUtils.toSQLException
(SqlUtils.java:68)
at
com.mchange.v2.sql.SqlUtils.toSQLException
(SqlUtils.java:57)
at
com.mchange.v2.c3p0.stmt.GooGooStatementCache.ac
quireStatement(GooGooStatementCache.java:368)
at
com.mchange.v2.c3p0.stmt.GooGooStatementCache.ch
eckoutStatement(GooGooStatementCache.java:85)
at
com.mchange.v2.c3p0.impl.NewPooledConnection.chec
koutStatement(NewPooledConnection.java:138)
at
com.mchange.v2.c3p0.impl.NewProxyConnection.prepar
eStatement(NewProxyConnection.java:184)
at
com.intruvert.utility.dao.AbstractDAO.executeSQL
(AbstractDAO.java:224)
at
com.intruvert.utility.dao.AbstractDAO.executeSQL
(AbstractDAO.java:327)
at
com.intruvert.utility.dao.AbstractDAO.executeSQL
(AbstractDAO.java:415)

------------------------------------------

This exception is thrown at the line "statement
conn.prepareStatement(SQL); " . Below changes in my
code works but is it a good solution ? I think this should
be handled in C3P0.

Code changes:
-------------------------------------------------------------

boolean isAvailable = false;
int count = 1 ;

while(!isAvailable){

System.out.println("---- Try # "+count) ;

try{
stmt = conn.prepareStatement(SQL);
isAvailable = true;

}catch(Exception e3) {

System.out.println(" --- Error
creating statement --- "+count);
System.out.println(" ---
Exception--- "+ e3);
System.out.println("Sleeping for
2 secs");

try{
Thread.sleep(2000);

}catch
(java.lang.InterruptedException e4){

System.out.println
(e4);
}

}

count++ ;
}
-------------------------------------------------

Any sugestions/fix is very much appreciated.

- PKumar

Discussion

  • Nobody/Anonymous

    Logged In: NO

    My email id is prasannabp@gmail.com

     
  • Steve Waldman

    Steve Waldman - 2005-05-19

    Logged In: YES
    user_id=175530

    Hi.

    1) You certainly shouldn't have to use a workaround like the
    one provided.

    2) Please provide me with more information: i) c3p0 config
    output, including version and build banner and configuration
    dump; ii) what more exactly are you doing? are you preparing
    multiple copies of the same statement over and over, or just
    randomly, occasionally in an app that does lots of things
    you see this Exception?

    3) This is rather strange, because someone is apparently
    calling interrupt() on your Thread! c3p0 doesn't know
    anything about this Thread, and in the Statement pool
    (unlike the Connection pool), c3p0 itself never calls
    interrupt() on client Threads. Are you sure there is nothing
    in your application (or in the container that manages it)
    that would try to interrupt() your Thread?

     
  • Nobody/Anonymous

    Logged In: NO

    Hi,
    Thanks for your quick response.
    1) config details and dump are at end

    2) c3p0 version is c3p0-0.8.5.2 ( I even tried with latest
    version also)

    3) My code has a simple method which makes a connection
    and executes SQL statement. This method is called
    repeatedly to perform operation. Error is occuring at the line
    Statement st = conn.prepareStatement(SQL)

    4) This error is occuring occasionally in my application

    5) I will go through my code again to see whether any thread
    is calling interrupt.

    Hope this information is sufficient.

    config details and dump
    -----------------------------------
    2005-05-19 17:08:05,500 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory - c3po
    configuration values:
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.maxStatements = 350
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.initialPoolSize = 10
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxxx.utility.dao.C3POConnectionFactory -
    c3po.connection.minPoolSize = 10
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.maxPoolSize = 40
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.idleConnectionTestPeriod = 300
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.maxIdleTime = 300
    2005-05-19 17:08:05,531 INFO [ThreadPoolWorker[1]]
    com.xxx.utility.dao.C3POConnectionFactory -
    c3po.connection.maxRetryAttempts = 60
    2005-05-19 17:08:05,609 INFO [ThreadPoolWorker[1]]
    STDOUT - Initializing c3p0 pool...
    com.mchange.v2.c3p0.PoolBackedDataSource@12504e0 [
    connectionPoolDataSource ->
    com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@
    ba06ff [ acquireIncrement -> 3, acquireRetryAttempts -> 60,
    acquireRetryDelay -> 1000, autoCommitOnClose -> false,
    automaticTestTable -> null, breakAfterAcquireFailure -> false,
    checkoutTimeout -> 0, connectionTesterClassName ->
    com.mchange.v2.c3p0.impl.DefaultConnectionTester,
    factoryClassLocation -> null,
    forceIgnoreUnresolvedTransactions -> false,
    idleConnectionTestPeriod -> 300, initialPoolSize -> 10,
    maxIdleTime -> 300, maxPoolSize -> 40, maxStatements ->
    350, maxStatementsPerConnection -> 0, minPoolSize -> 10,
    nestedDataSource ->
    com.mchange.v2.c3p0.DriverManagerDataSource@1f0cbfb [
    description -> null, driverClass -> org.gjt.mm.mysql.Driver,
    factoryClassLocation -> null, jdbcUrl ->
    jdbc:mysql://localhost:3306/db, properties -> {user=******,
    password=******} ] , preferredTestQuery -> null,
    propertyCycle -> 300, testConnectionOnCheckin -> false,
    testConnectionOnCheckout -> false,
    usesTraditionalReflectiveProxies -> false ] ,
    factoryClassLocation -> null, numHelperThreads -> 3,
    poolOwnerIdentityToken -> 12504e0 ]

    --------------------------------

    Thanks again,
    Pkumar

     
  • Nobody/Anonymous

    Logged In: NO

    I couldn't find any problem in my code. It is just a simple java
    file to execute SQL statements using c3p0

     
  • Steve Waldman

    Steve Waldman - 2006-09-07

    Logged In: YES
    user_id=175530

    i am going through outstanding c3p0 issues, and don't
    remember where we left this... is this issue resolved?

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks