Search in sources :

Example 1 with SuspendableXAConnection

use of com.mysql.cj.jdbc.SuspendableXAConnection in project JavaSegundasQuintas by ecteruel.

the class ConnectionRegressionTest method testBug62452.

/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 *
 * @throws Exception
 */
@Test
public void testBug62452() throws Exception {
    PooledConnection con = null;
    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    pds.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    pds.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    con = pds.getPooledConnection();
    assertTrue(con instanceof MysqlPooledConnection);
    testBug62452WithConnection(con);
    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);
    xads.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof MysqlXAConnection);
    testBug62452WithConnection(con);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof SuspendableXAConnection);
    testBug62452WithConnection(con);
}
Also used : MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) PooledConnection(javax.sql.PooledConnection) MysqlXADataSource(com.mysql.cj.jdbc.MysqlXADataSource) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) MysqlXAConnection(com.mysql.cj.jdbc.MysqlXAConnection) MysqlConnectionPoolDataSource(com.mysql.cj.jdbc.MysqlConnectionPoolDataSource) MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) Test(org.junit.jupiter.api.Test)

Example 2 with SuspendableXAConnection

use of com.mysql.cj.jdbc.SuspendableXAConnection in project JavaSegundasQuintas by ecteruel.

the class ConnectionRegressionTest method testBug46925.

@Test
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();
    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);
    xads1.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads1.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads1.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    xads1.setUrl(dbUrl);
    xads2.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads2.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads2.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    xads2.setUrl(dbUrl);
    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);
    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    // this will fail without the fix.
    c2.getXAResource().prepare(txid);
    c2.getXAResource().commit(txid, false);
}
Also used : MysqlXid(com.mysql.cj.jdbc.MysqlXid) Xid(javax.transaction.xa.Xid) MysqlXADataSource(com.mysql.cj.jdbc.MysqlXADataSource) MysqlXid(com.mysql.cj.jdbc.MysqlXid) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) XAConnection(javax.sql.XAConnection) MysqlXAConnection(com.mysql.cj.jdbc.MysqlXAConnection) Test(org.junit.jupiter.api.Test)

Example 3 with SuspendableXAConnection

use of com.mysql.cj.jdbc.SuspendableXAConnection in project ABC by RuiPinto96274.

the class ConnectionRegressionTest method testBug62452.

/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 *
 * @throws Exception
 */
@Test
public void testBug62452() throws Exception {
    PooledConnection con = null;
    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    pds.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    pds.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    con = pds.getPooledConnection();
    assertTrue(con instanceof MysqlPooledConnection);
    testBug62452WithConnection(con);
    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);
    xads.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof MysqlXAConnection);
    testBug62452WithConnection(con);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof SuspendableXAConnection);
    testBug62452WithConnection(con);
}
Also used : MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) PooledConnection(javax.sql.PooledConnection) MysqlXADataSource(com.mysql.cj.jdbc.MysqlXADataSource) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) MysqlXAConnection(com.mysql.cj.jdbc.MysqlXAConnection) MysqlConnectionPoolDataSource(com.mysql.cj.jdbc.MysqlConnectionPoolDataSource) MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) Test(org.junit.jupiter.api.Test)

Example 4 with SuspendableXAConnection

use of com.mysql.cj.jdbc.SuspendableXAConnection in project ABC by RuiPinto96274.

the class ConnectionRegressionTest method testBug46925.

@Test
public void testBug46925() throws Exception {
    MysqlXADataSource xads1 = new MysqlXADataSource();
    MysqlXADataSource xads2 = new MysqlXADataSource();
    Xid txid = new MysqlXid(new byte[] { 0x1 }, new byte[] { 0xf }, 3306);
    xads1.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads1.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads1.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    xads1.setUrl(dbUrl);
    xads2.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads2.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads2.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    xads2.setUrl(dbUrl);
    XAConnection c1 = xads1.getXAConnection();
    assertTrue(c1 instanceof SuspendableXAConnection);
    // start a transaction on one connection
    c1.getXAResource().start(txid, XAResource.TMNOFLAGS);
    c1.getXAResource().end(txid, XAResource.TMSUCCESS);
    XAConnection c2 = xads2.getXAConnection();
    assertTrue(c2 instanceof SuspendableXAConnection);
    // prepare on another one. Since we are using a "pinned" connection we should have the same "currentXAConnection" for both SuspendableXAConnection
    // this will fail without the fix.
    c2.getXAResource().prepare(txid);
    c2.getXAResource().commit(txid, false);
}
Also used : MysqlXid(com.mysql.cj.jdbc.MysqlXid) Xid(javax.transaction.xa.Xid) MysqlXADataSource(com.mysql.cj.jdbc.MysqlXADataSource) MysqlXid(com.mysql.cj.jdbc.MysqlXid) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) XAConnection(javax.sql.XAConnection) MysqlXAConnection(com.mysql.cj.jdbc.MysqlXAConnection) Test(org.junit.jupiter.api.Test)

Example 5 with SuspendableXAConnection

use of com.mysql.cj.jdbc.SuspendableXAConnection in project aws-mysql-jdbc by awslabs.

the class ConnectionRegressionTest method testBug62452.

/**
 * Tests fix for BUG#62452 - NPE thrown in JDBC4MySQLPooledException when statement is closed.
 *
 * @throws Exception
 */
@Test
public void testBug62452() throws Exception {
    PooledConnection con = null;
    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    pds.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    pds.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    con = pds.getPooledConnection();
    assertTrue(con instanceof MysqlPooledConnection);
    testBug62452WithConnection(con);
    MysqlXADataSource xads = new MysqlXADataSource();
    xads.setUrl(dbUrl);
    xads.getStringProperty(PropertyKey.sslMode.getKeyName()).setValue("DISABLED");
    xads.getBooleanProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName()).setValue(true);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(false);
    con = xads.getXAConnection();
    assertTrue(con instanceof MysqlXAConnection);
    testBug62452WithConnection(con);
    xads.getProperty(PropertyKey.pinGlobalTxToPhysicalConnection).setValue(true);
    con = xads.getXAConnection();
    assertTrue(con instanceof SuspendableXAConnection);
    testBug62452WithConnection(con);
}
Also used : MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) PooledConnection(javax.sql.PooledConnection) MysqlXADataSource(com.mysql.cj.jdbc.MysqlXADataSource) SuspendableXAConnection(com.mysql.cj.jdbc.SuspendableXAConnection) MysqlXAConnection(com.mysql.cj.jdbc.MysqlXAConnection) MysqlConnectionPoolDataSource(com.mysql.cj.jdbc.MysqlConnectionPoolDataSource) MysqlPooledConnection(com.mysql.cj.jdbc.MysqlPooledConnection) Test(org.junit.jupiter.api.Test)

Aggregations

MysqlXAConnection (com.mysql.cj.jdbc.MysqlXAConnection)6 MysqlXADataSource (com.mysql.cj.jdbc.MysqlXADataSource)6 SuspendableXAConnection (com.mysql.cj.jdbc.SuspendableXAConnection)6 Test (org.junit.jupiter.api.Test)6 MysqlConnectionPoolDataSource (com.mysql.cj.jdbc.MysqlConnectionPoolDataSource)3 MysqlPooledConnection (com.mysql.cj.jdbc.MysqlPooledConnection)3 MysqlXid (com.mysql.cj.jdbc.MysqlXid)3 PooledConnection (javax.sql.PooledConnection)3 XAConnection (javax.sql.XAConnection)3 Xid (javax.transaction.xa.Xid)3