use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_setClientInfo.
public void test_setClientInfo() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.close();
{
SQLException error = null;
try {
conn.setClientInfo("name", "xxx");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest4 method test_prepareStatement.
public void test_prepareStatement() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
Assert.assertSame(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest4 method test_prepareStatement_3.
public void test_prepareStatement_3() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", new String[0]);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", new String[0]);
Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest4 method test_prepCall_1.
public void test_prepCall_1() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.getConnectionHolder().toString();
conn.getConnectionHolder().setLastActiveTimeMillis(0);
conn.getConnectionHolder().toString();
conn.getConnectionHolder().getUseCount();
conn.getConnectionHolder().getTimeMillis();
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest4 method test_rollback_1.
public void test_rollback_1() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.getConnection().close();
{
SQLException error = null;
try {
conn.rollback(null);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
conn.close();
}
Aggregations