本文整理汇总了Java中com.mysql.jdbc.jdbc2.optional.ConnectionWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionWrapper类的具体用法?Java ConnectionWrapper怎么用?Java ConnectionWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionWrapper类属于com.mysql.jdbc.jdbc2.optional包,在下文中一共展示了ConnectionWrapper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPacketTooLargeException
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
/**
* 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);
}
示例2: testPacketTooLargeException
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
/**
* 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);
}
示例3: JDBC4PreparedStatementWrapper
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) {
super(c, conn, toWrap);
}
示例4: JDBC42CallableStatementWrapper
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC42CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) {
super(c, conn, toWrap);
}
示例5: JDBC4CallableStatementWrapper
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) {
super(c, conn, toWrap);
}
示例6: JDBC4StatementWrapper
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4StatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, Statement toWrap) {
super(c, conn, toWrap);
}
示例7: JDBC42PreparedStatementWrapper
import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC42PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) {
super(c, conn, toWrap);
}