com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection Java Examples

The following examples show how to use com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionRegressionTest.java    From r-course with MIT License 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example #2
Source File: ConnectionRegressionTest.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 * 
 * @throws Exception
 */
public void testBug62452() throws Exception {
    PooledConnection con = null;

    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    con = pds.getPooledConnection();
    assertTrue(con instanceof JDBC4MysqlPooledConnection);
    testBug62452WithConnection(con);

    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);

    xads.setPinGlobalTxToPhysicalConnection(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4MysqlXAConnection);
    testBug62452WithConnection(con);

    xads.setPinGlobalTxToPhysicalConnection(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof JDBC4SuspendableXAConnection);
    testBug62452WithConnection(con);

}
 
Example #3
Source File: MysqlUtils.java    From clearpool with GNU General Public License v3.0 5 votes vote down vote up
public static XAConnection mysqlXAConnection(Connection con) throws SQLException {
  ConnectionImpl mysqlConn = (ConnectionImpl) con;
  if (mysqlConn.getPinGlobalTxToPhysicalConnection()) {
    if (!Util.isJdbc4()) {
      return new SuspendableXAConnection(mysqlConn);
    }
    return new JDBC4SuspendableXAConnection(mysqlConn);
  }
  return new MysqlXAConnection(mysqlConn, false);
}