use of com.alibaba.druid.pool.DruidPooledStatement in project druid by alibaba.
the class ResultSetTest2 method setUp.
protected void setUp() throws Exception {
stmt = new DruidPooledStatement(null, null) {
protected SQLException checkException(Throwable error) throws SQLException {
if (error instanceof SQLException) {
return (SQLException) error;
}
return new SQLException(error);
}
};
raw = new MockResultSet(null);
raw.getRows().add(new Object[] { null });
resultSet = new DruidPooledResultSet(stmt, raw);
}
use of com.alibaba.druid.pool.DruidPooledStatement in project druid by alibaba.
the class PoolableStatementTest3 method test_clearResultSetError.
public void test_clearResultSetError() throws Exception {
final MockResultSet rs = new MockResultSet(null) {
public void close() throws SQLException {
throw new SQLException();
}
};
DruidPooledStatement stmt = new DruidPooledStatement(null, null) {
public void close() throws SQLException {
addResultSetTrace(rs);
clearResultSet();
}
};
stmt.close();
}
use of com.alibaba.druid.pool.DruidPooledStatement in project druid by alibaba.
the class PoolableStatementTest2 method test_execute_2.
public void test_execute_2() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS);
((DruidPooledStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledStatement in project druid by alibaba.
the class PoolableStatementTest2 method test_QueryTimeout.
public void test_QueryTimeout() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.setQueryTimeout(33);
Assert.assertEquals(33, stmt.getQueryTimeout());
((DruidPooledStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.getQueryTimeout();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.setQueryTimeout(23);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledStatement in project druid by alibaba.
the class PoolableStatementTest2 method test_execute_error.
public void test_execute_error() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
((DruidPooledStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.execute("SET @VAR = 1");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
Aggregations