use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest3 method test_basic.
public void test_basic() throws Exception {
DruidPooledConnection conn = (DruidPooledConnection) dataSource.getConnection();
conn.getTransactionInfo();
conn.getMetaData();
conn.setReadOnly(true);
Assert.assertEquals(true, conn.isReadOnly());
conn.setCatalog("xxx");
Assert.assertEquals("xxx", conn.getCatalog());
conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Assert.assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn.getTransactionIsolation());
conn.getWarnings();
conn.clearWarnings();
conn.getTypeMap();
conn.setTypeMap(null);
conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, conn.getHoldability());
conn.setSavepoint();
conn.setSavepoint("savepoint");
conn.rollback();
{
Exception error = null;
try {
conn.rollback(null);
} catch (SQLException e) {
error = e;
}
Assert.assertNotNull(error);
}
{
Exception error = null;
try {
conn.releaseSavepoint(null);
} catch (SQLException e) {
error = e;
}
Assert.assertNotNull(error);
}
conn.createBlob();
conn.createClob();
conn.createNClob();
conn.createSQLXML();
conn.isValid(200);
conn.setClientInfo(new Properties());
conn.setClientInfo("xx", "11");
conn.getClientInfo("xx");
conn.getClientInfo();
conn.createArrayOf("int", new Object[0]);
conn.createStruct("int", new Object[0]);
conn.addConnectionEventListener(null);
conn.removeConnectionEventListener(null);
conn.addStatementEventListener(null);
conn.removeStatementEventListener(null);
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_basic.
public void test_basic() throws Exception {
DruidPooledConnection conn = (DruidPooledConnection) dataSource.getConnection();
conn.close();
Assert.assertEquals(true, dataSource.isResetStatEnable());
dataSource.setResetStatEnable(false);
Assert.assertEquals(false, dataSource.isResetStatEnable());
Assert.assertEquals(1, dataSource.getConnectCount());
dataSource.resetStat();
Assert.assertEquals(1, dataSource.getConnectCount());
dataSource.setResetStatEnable(true);
dataSource.resetStat();
Assert.assertEquals(0, dataSource.getConnectCount());
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_handleException_4.
public void test_handleException_4() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.getConnection().close();
{
SQLException error = null;
try {
conn.prepareStatement("SELECT 1");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Assert.assertEquals(true, conn.isClosed());
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_handleException_3.
public void test_handleException_3() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.getConnection().close();
{
SQLException error = null;
try {
conn.handleException(new RuntimeException());
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_handleException_2.
public void test_handleException_2() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.getConnection().close();
{
SQLException error = null;
try {
conn.handleException(new RuntimeException());
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
conn.close();
}
Aggregations