当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionWrapper类代码示例

本文整理汇总了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);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:42,代码来源:PooledConnectionRegressionTest.java

示例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);
}
 
开发者ID:mniepert,项目名称:TPKB,代码行数:42,代码来源:PooledConnectionRegressionTest.java

示例3: JDBC4PreparedStatementWrapper

import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) {
    super(c, conn, toWrap);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:JDBC4PreparedStatementWrapper.java

示例4: JDBC42CallableStatementWrapper

import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC42CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) {
    super(c, conn, toWrap);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:JDBC42CallableStatementWrapper.java

示例5: JDBC4CallableStatementWrapper

import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) {
    super(c, conn, toWrap);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:JDBC4CallableStatementWrapper.java

示例6: JDBC4StatementWrapper

import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC4StatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, Statement toWrap) {
    super(c, conn, toWrap);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:JDBC4StatementWrapper.java

示例7: JDBC42PreparedStatementWrapper

import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper; //导入依赖的package包/类
public JDBC42PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) {
    super(c, conn, toWrap);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:JDBC42PreparedStatementWrapper.java


注:本文中的com.mysql.jdbc.jdbc2.optional.ConnectionWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。