use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class OracleExceptionSorterTest_setCatalog method test_connect.
public void test_connect() throws Exception {
String sql = "SELECT 1";
{
DruidPooledConnection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.execute();
pstmt.close();
conn.close();
Assert.assertEquals(0, dataSource.getActiveCount());
Assert.assertEquals(1, dataSource.getPoolingCount());
Assert.assertEquals(1, dataSource.getCreateCount());
}
DruidPooledConnection conn = dataSource.getConnection();
MockConnection mockConn = conn.unwrap(MockConnection.class);
Assert.assertNotNull(mockConn);
SQLException exception = new SQLException("xx", "xxx", 28);
mockConn.setError(exception);
Exception setError = null;
try {
conn.setCatalog("xxx");
} catch (Exception ex) {
setError = ex;
}
Assert.assertNotNull(setError);
conn.close();
{
Connection conn2 = dataSource.getConnection();
conn2.close();
}
Assert.assertEquals(0, dataSource.getActiveCount());
Assert.assertEquals(1, dataSource.getPoolingCount());
Assert.assertEquals(2, dataSource.getCreateCount());
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class OracleExceptionSorterTest_stmt_getFetchSize method test_connect.
public void test_connect() throws Exception {
String sql = "SELECT 1";
{
DruidPooledConnection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.execute();
pstmt.close();
conn.close();
}
DruidPooledConnection conn = dataSource.getConnection();
MockConnection mockConn = conn.unwrap(MockConnection.class);
Assert.assertNotNull(mockConn);
Statement stmt = conn.createStatement();
SQLException exception = new SQLException("xx", "xxx", 28);
mockConn.setError(exception);
SQLException stmtErrror = null;
try {
stmt.getFetchSize();
} catch (SQLException ex) {
stmtErrror = ex;
}
Assert.assertNotNull(stmtErrror);
Assert.assertSame(exception, stmtErrror);
SQLException commitError = null;
try {
conn.commit();
} catch (SQLException ex) {
commitError = ex;
}
Assert.assertNotNull(commitError);
Assert.assertSame(exception, commitError.getCause());
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class OracleExceptionSorterTest_stmt_getMaxField method test_connect.
public void test_connect() throws Exception {
String sql = "SELECT 1";
{
DruidPooledConnection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.execute();
pstmt.close();
conn.close();
}
DruidPooledConnection conn = dataSource.getConnection();
MockConnection mockConn = conn.unwrap(MockConnection.class);
Assert.assertNotNull(mockConn);
Statement stmt = conn.createStatement();
SQLException exception = new SQLException("xx", "xxx", 28);
mockConn.setError(exception);
SQLException stmtErrror = null;
try {
stmt.getMaxFieldSize();
} catch (SQLException ex) {
stmtErrror = ex;
}
Assert.assertNotNull(stmtErrror);
Assert.assertSame(exception, stmtErrror);
SQLException commitError = null;
try {
conn.commit();
} catch (SQLException ex) {
commitError = ex;
}
Assert.assertNotNull(commitError);
Assert.assertSame(exception, commitError.getCause());
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class OracleExceptionSorterTest_stmt_getMoreResults method test_connect.
public void test_connect() throws Exception {
String sql = "SELECT 1";
{
DruidPooledConnection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.execute();
pstmt.close();
conn.close();
}
DruidPooledConnection conn = dataSource.getConnection();
MockConnection mockConn = conn.unwrap(MockConnection.class);
Assert.assertNotNull(mockConn);
Statement stmt = conn.createStatement();
stmt.execute(sql);
SQLException exception = new SQLException("xx", "xxx", 28);
mockConn.setError(exception);
SQLException stmtErrror = null;
try {
stmt.getMoreResults();
} catch (SQLException ex) {
stmtErrror = ex;
}
Assert.assertNotNull(stmtErrror);
Assert.assertSame(exception, stmtErrror);
SQLException commitError = null;
try {
conn.commit();
} catch (SQLException ex) {
commitError = ex;
}
Assert.assertNotNull(commitError);
Assert.assertSame(exception, commitError.getCause());
conn.close();
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class OracleExceptionSorterTest_stmt_getQueryTimeout method test_connect.
public void test_connect() throws Exception {
String sql = "SELECT 1";
{
DruidPooledConnection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.execute();
pstmt.close();
conn.close();
}
DruidPooledConnection conn = dataSource.getConnection();
MockConnection mockConn = conn.unwrap(MockConnection.class);
Assert.assertNotNull(mockConn);
Statement stmt = conn.createStatement();
SQLException exception = new SQLException("xx", "xxx", 28);
mockConn.setError(exception);
SQLException stmtErrror = null;
try {
stmt.getQueryTimeout();
} catch (SQLException ex) {
stmtErrror = ex;
}
Assert.assertNotNull(stmtErrror);
Assert.assertSame(exception, stmtErrror);
SQLException commitError = null;
try {
conn.commit();
} catch (SQLException ex) {
commitError = ex;
}
Assert.assertNotNull(commitError);
Assert.assertSame(exception, commitError.getCause());
conn.close();
}
Aggregations