use of com.alibaba.druid.pool.DruidPooledCallableStatement in project druid by alibaba.
the class PoolableCallableStatementTest method setUp.
protected void setUp() throws Exception {
MockConnection mockConn = new MockConnection();
DruidConnectionHolder connHolder = new DruidConnectionHolder(dataSource, mockConn, 0);
conn = new DruidPooledConnection(connHolder);
raw = new MockCallableStatement(null, null);
stmt = new DruidPooledCallableStatement(conn, new PreparedStatementHolder(new PreparedStatementKey("", null, null, 0, 0, 0), raw)) {
protected SQLException checkException(Throwable error) throws SQLException {
if (error instanceof SQLException) {
return (SQLException) error;
}
return new SQLException(error);
}
};
Assert.assertEquals(0, raw.getOutParameters().size());
stmt.registerOutParameter(1, Types.INTEGER);
Assert.assertEquals(1, raw.getOutParameters().size());
stmt.registerOutParameter(2, Types.DECIMAL, 10);
Assert.assertEquals(2, raw.getOutParameters().size());
}
use of com.alibaba.druid.pool.DruidPooledCallableStatement in project druid by alibaba.
the class DruidPooledCallableStatementTest method test_getObject_1.
public void test_getObject_1() throws Exception {
Connection conn = dataSource.getConnection();
DruidPooledCallableStatement stmt = (DruidPooledCallableStatement) conn.prepareCall("select 1");
stmt.execute();
Assert.assertEquals(0, dataSource.getErrorCount());
Exception error = null;
try {
stmt.getObject("1", String.class);
} catch (SQLFeatureNotSupportedException e) {
error = e;
}
Assert.assertNotNull(error);
Assert.assertEquals(0, dataSource.getErrorCount());
stmt.close();
conn.close();
Assert.assertEquals(1, dataSource.getPoolingCount());
}
use of com.alibaba.druid.pool.DruidPooledCallableStatement in project druid by alibaba.
the class DruidPooledCallableStatementTest method test_getObject.
public void test_getObject() throws Exception {
Connection conn = dataSource.getConnection();
DruidPooledCallableStatement stmt = (DruidPooledCallableStatement) conn.prepareCall("select 1");
stmt.execute();
Assert.assertEquals(0, dataSource.getErrorCount());
Exception error = null;
try {
stmt.getObject(1, String.class);
} catch (SQLFeatureNotSupportedException e) {
error = e;
}
Assert.assertNotNull(error);
Assert.assertEquals(0, dataSource.getErrorCount());
stmt.close();
conn.close();
Assert.assertEquals(1, dataSource.getPoolingCount());
}
Aggregations