/** * Tests that PacketTooLargeException doesn't clober the connection. * * @throws Exception * if the test fails. */ public void testPacketTooLargeException() throws Exception { final ConnectionEventListener conListener = new ConnectionListener(); PooledConnection pc = null; pc = this.cpds.getPooledConnection(); pc.addConnectionEventListener(conListener); createTable("testPacketTooLarge", "(field1 LONGBLOB)"); Connection connFromPool = pc.getConnection(); PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool).clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)"); this.rs = this.stmt.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'"); this.rs.next(); int maxAllowedPacket = this.rs.getInt(2); int numChars = (int) (maxAllowedPacket * 1.2); pstmtFromPool.setBinaryStream(1, new BufferedInputStream(new FileInputStream(newTempBinaryFile("testPacketTooLargeException", numChars))), numChars); try { pstmtFromPool.executeUpdate(); fail("Expecting PacketTooLargeException"); } catch (PacketTooBigException ptbe) { // We're expecting this one... } // This should still work okay, even though the last query on the same connection didn't... this.rs = connFromPool.createStatement().executeQuery("SELECT 1"); assertTrue(this.connectionErrorEventCount == 0); assertTrue(this.closeEventCount == 0); }
/** * Tests that PacketTooLargeException doesn't clober the connection. * * @throws Exception * if the test fails. */ public void testPacketTooLargeException() throws Exception { final ConnectionEventListener conListener = new ConnectionListener(); PooledConnection pc = null; pc = this.cpds.getPooledConnection(); pc.addConnectionEventListener(conListener); createTable("testPacketTooLarge", "(field1 LONGBLOB)"); Connection connFromPool = pc.getConnection(); PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool).clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)"); this.rs = this.stmt.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'"); this.rs.next(); int maxAllowedPacket = this.rs.getInt(2); int numChars = (int) (maxAllowedPacket * 1.2); pstmtFromPool.setBinaryStream(1, new BufferedInputStream(new FileInputStream(newTempBinaryFile("testPacketTooLargeException", numChars))), numChars); try { pstmtFromPool.executeUpdate(); fail("Expecting PacketTooLargeException"); } catch (PacketTooBigException ptbe) { // We're expecting this one... } // This should still work okay, even though the last query on the same connection didn't... connFromPool.createStatement().executeQuery("SELECT 1"); assertTrue(this.connectionErrorEventCount == 0); assertTrue(this.closeEventCount == 0); }
public JDBC4PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) { super(c, conn, toWrap); }
public JDBC42CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) { super(c, conn, toWrap); }
public JDBC4CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) { super(c, conn, toWrap); }
public JDBC4StatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, Statement toWrap) { super(c, conn, toWrap); }
public JDBC42PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) { super(c, conn, toWrap); }