Esempio n. 1
0
  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();
  }
Esempio n. 2
0
  public void test_prepCall() 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,
              ResultSet.HOLD_CURSORS_OVER_COMMIT);
      raw = stmt.unwrap(MockPreparedStatement.class);
      stmt.close();
    }
    {
      PreparedStatement stmt =
          conn.prepareCall(
              "SELECT 1",
              ResultSet.TYPE_FORWARD_ONLY,
              ResultSet.CONCUR_READ_ONLY,
              ResultSet.HOLD_CURSORS_OVER_COMMIT);
      Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
      stmt.close();
    }

    conn.close();
  }
Esempio n. 3
0
  public static OraclePreparedStatement unwrapInternal(PreparedStatement stmt) throws SQLException {
    if (stmt instanceof OraclePreparedStatement) {
      return (OraclePreparedStatement) stmt;
    }

    return stmt.unwrap(OraclePreparedStatement.class);
  }
 public <T> T unwrap(Class<T> iface) throws SQLException {
   try {
     return wrapped.unwrap(iface);
   } catch (SQLException e) {
     throw new UcanaccessSQLException(e);
   }
 }
Esempio n. 5
0
  public void test_prepareStatement_4() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    MockPreparedStatement raw = null;
    {
      PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
      raw = stmt.unwrap(MockPreparedStatement.class);
      stmt.close();
    }
    {
      PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
      Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
      stmt.close();
    }

    conn.close();
  }
 public <T> T unwrap(Class<T> iface) throws SQLException {
   String methodCall = "unwrap(" + (iface == null ? "null" : iface.getName()) + ")";
   try {
     // todo: double check this logic
     // NOTE: could call super.isWrapperFor to simplify this logic, but it would result in extra
     // log output
     // because the super classes would be invoked, thus executing their logging methods too...
     return (T)
         reportReturn(
             methodCall,
             (iface != null
                     && (iface == PreparedStatement.class
                         || iface == Statement.class
                         || iface == Spy.class))
                 ? (T) this
                 : realPreparedStatement.unwrap(iface));
   } catch (SQLException s) {
     reportException(methodCall, s);
     throw s;
   }
 }
Esempio n. 7
0
 public static void setRowPrefetch(PreparedStatement stmt, int value) throws SQLException {
   OracleStatement oracleStmt = stmt.unwrap(OracleStatement.class);
   oracleStmt.setRowPrefetch(value);
 }
Esempio n. 8
0
 public static int getRowPrefetch(PreparedStatement stmt) throws SQLException {
   OracleStatement oracleStmt = stmt.unwrap(OracleStatement.class);
   return oracleStmt.getRowPrefetch();
 }
 public <T> T unwrap(Class<T> iface) throws SQLException {
   this.assertPs();
   return ps.unwrap(iface);
 }
 public <T> T unwrap(Class<T> iface) throws SQLException {
   return delegate.unwrap(iface);
 }
 @Override
 public <T> T unwrap(Class<T> iface) throws SQLException {
   return stmt.unwrap(iface);
 }