Harrison
Harrison

Reputation: 430

Java C3P0 pooled database connection resulting in "Unable to obtain storage for thread control block"

I'm having a problem with C3P0 and java where I'm creating a pool and then I do a test query and it works fine...until the test query is over. I get this huge error after the successful query and my attempt to close the connection.

The code:

package database;
import com.mchange.v2.c3p0.*;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import java.io.IOException;
import java.sql.Statement;
import java.sql.ResultSet; 
public class Datasource {
    private ComboPooledDataSource cpds;
    private static Datasource datasource;

    private Datasource() throws IOException, SQLException {

        cpds = new ComboPooledDataSource();

        try {
            cpds.setDriverClass("com.mysql.jdbc.Driver");
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }

        cpds.setJdbcUrl("[removed for safety]");
        cpds.setUser("[removed for safety]");
        cpds.setPassword("[removed for safety]");
        cpds.setMinPoolSize(5);
        cpds.setAcquireIncrement(5);
        cpds.setMaxPoolSize(10);

        Connection testConnection = null;
        Statement testStatement = null;
        ResultSet rs = null; 
        // test connectivity and initialize pool
        try {
               testConnection = cpds.getConnection();
               testStatement = testConnection.createStatement();
               rs = testStatement.executeQuery("SELECT * From ScoreBoard");
               while (rs.next()) {
                String id = rs.getString("ScoreBoardID");
                System.out.println("ID: " + id);
            }
            } catch (SQLException e) {
                throw e;
            } finally {
                testStatement.close();
                testConnection.close();
        }

    }

    public static Datasource getInstance() throws IOException, SQLException {
        if (datasource == null) {
              datasource = new Datasource();
              return datasource;
            } else {
              return datasource;
            }
    }

    public Connection getConnection() throws SQLException {
        return this.cpds.getConnection();
    }
}

The only thing I'm doing in main is calling

Datasource ds = Datasource.getInstance();

Here is the crazy error:

UTE019: Unable to obtain storage for thread control block  UTE thread start failed for thread 00007FEFB4F37900 Unhandled exception Type=Segmentation error vmState=0x000540ff J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001 Handler1=00007FEFBBA02C80 Handler2=00007FEFBB6BBFF0 InaccessibleAddress=0000000000000038 RDI=0000000000000000 RSI=0000000000000010 RAX=00000000B4062808 RBX=00007FEF881ED670 RCX=00007FEFB418DFB0 RDX=0000000000000020 R8=00007FEFB868D708 R9=00007FEFB868D710 R10=0000000000000047 R11=00007FEFB419E2F8 R12=00007FEFB868D83B R13=0000000000000010 R14=00007FEFB868D850 R15=0000000000000000 RIP=00007FEFBA481D1C GS=0000 FS=0000 RSP=00007FEFB868D740 EFlags=0000000000210202 CS=0033 RBP=0000000000000000 ERR=0000000000000004 TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000038 xmm0 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm1 0000000000000000 (f: 0.000000, d:
0.000000e+00) xmm2 7173796d2f6d6f63 (f: 795701120.000000, d: 3.170290e+238) xmm3 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm4 4040404040404040 (f: 1077952512.000000, d: 3.250196e+01) xmm5 5b5b5b5b5b5b5b5b (f: 1532713856.000000, d: 1.213625e+132) xmm6 2020202020202020 (f: 538976256.000000, d: 6.013470e-154) xmm7 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm8 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm9 0000000000000000 (f: 0.000000, d:
0.000000e+00) xmm10 ff000000000000ff (f: 255.000000, d: -5.486124e+303) xmm11 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm12 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm13 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm14 0000000000000000 (f: 0.000000, d: 0.000000e+00) xmm15 0000000000000000 (f: 0.000000, d:
0.000000e+00) Module=/usr/lib/jvm/java-1.6.0-ibm-1.6.0.14.0.x86_64/jre/lib/amd64/default/libj9jit24.so Module_base_address=00007FEFBA391000

Method_being_compiled=com/mysql/jdbc/Field.getSQLType()I Target=2_40_20130704_155156 (Linux 2.6.32-358.18.1.el6.x86_64) CPU=amd64 (8 logical CPUs) (0x1ebfd7000 RAM)
----------- Stack Backtrace ----------- (0x00007FEFBA481D1C [libj9jit24.so+0xf0d1c]) (0x00007FEFBA481CEE [libj9jit24.so+0xf0cee]) (0x00007FEFBA70E19D [libj9jit24.so+0x37d19d]) (0x00007FEF4C1F7210 [<unknown>+0x0])
--------------------------------------- JVMDUMP039I Processing dump event "gpf", detail "" at 2013/10/08 13:52:31 - please wait. JVMDUMP032I JVM requested System dump using '/students/8/hhnvx8/capstone/DBTest/core.20131008.135231.7921.0001.dmp' in response to an event JVMPORT030W /proc/sys/kernel/core_pattern setting "|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e" specifies that the core dump is to be piped to an external program.  Attempting to rename either core or core.7964.

JVMDUMP010I System dump written to /students/8/hhnvx8/capstone/DBTest/core.20131008.135231.7921.0001.dmp JVMDUMP032I JVM requested Java dump using '/students/8/hhnvx8/capstone/DBTest/javacore.20131008.135231.7921.0002.txt' in response to an event JVMDUMP010I Java dump written to /students/8/hhnvx8/capstone/DBTest/javacore.20131008.135231.7921.0002.txt JVMDUMP032I JVM requested Snap dump using '/students/8/hhnvx8/capstone/DBTest/Snap.20131008.135231.7921.0003.trc' in response to an event JVMDUMP010I Snap dump written to /students/8/hhnvx8/capstone/DBTest/Snap.20131008.135231.7921.0003.trc JVMDUMP013I Processed dump event "gpf", detail "".

Unhandled exception in signal handler. Protected function: reportThreadCrash


Unhandled exception in signal handler. Protected function: executeAbortHook

I know it's probably not very likely anybody is going to know how to help me with this, but it's worth a shot and any assistance you provide will be met with gratitude.

Thanks

Upvotes: 0

Views: 471

Answers (1)

Thomas
Thomas

Reputation: 12009

It looks like you run this using an IBM JDK. Try with a current Oracle/Sun JDK, it might work out of the box. If you need to go with the IBM JDK, check your startup parameters, you may want to increase the memory limits.

Upvotes: 1

Related Questions