Examples of OraclePreparedStatement


Examples of oracle.jdbc.OraclePreparedStatement

     * @return
     * @throws SQLException
     */
    @Override
    public boolean registerPreparedStatementReturnParam(String sqlText, PreparedStatement ps, int idx) throws SQLException {
        OraclePreparedStatement ops = (OraclePreparedStatement) ps;
        Pattern p = Pattern.compile("^\\s*INSERT.+RETURNING.+INTO\\s+", Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(sqlText);
        if (m.find()) {
            ops.registerReturnParameter(idx, Types.BIGINT);
            return true;
        }
        return false;
    }
View Full Code Here

Examples of oracle.jdbc.OraclePreparedStatement

     * @return
     * @throws SQLException
     */
    @Override
    public long getPreparedStatementReturnParam(PreparedStatement ps) throws SQLException {
        OraclePreparedStatement ops = (OraclePreparedStatement) ps;
        ResultSet rs = ops.getReturnResultSet();
        try {
            if (rs.next()) {
                // Assuming that primary key will not be larger as long max value
                return rs.getLong(1);
            }
View Full Code Here

Examples of oracle.jdbc.OraclePreparedStatement

    {
      if(logger.isDebugEnabled())
        logger.debug("setSqlValue(value={}, column={}, statement={}) - start",
            new Object[]{value, new Integer(column), statement} );

        OraclePreparedStatement oraclePreparedStatement = (OraclePreparedStatement) statement;
        oraclePreparedStatement.setFormOfUse(column, OraclePreparedStatement.FORM_NCHAR);
        statement.setObject(column, getClob(value, statement.getConnection()));
    }
View Full Code Here

Examples of oracle.jdbc.OraclePreparedStatement

        return typeCast(data);
    }

    public void setSqlValue(Object value, int column, PreparedStatement statement) throws SQLException, TypeCastException
    {
        OraclePreparedStatement oraclePreparedStatement = (OraclePreparedStatement) statement;
        OpaqueDescriptor opaqueDescriptor = OpaqueDescriptor.createDescriptor("SYS.XMLTYPE", statement.getConnection());
        OPAQUE opaque = new OPAQUE(opaqueDescriptor, (byte[]) typeCast(value), statement.getConnection());
        oraclePreparedStatement.setOPAQUE(column, opaque);
    }
View Full Code Here

Examples of oracle.jdbc.OraclePreparedStatement

//           
//            PreparedStatement stmt2 = conn.prepareStatement(SQL);
//            stmt2.close();
//        }

        OraclePreparedStatement oracleStmt = null;
        PreparedStatement stmt = conn.prepareStatement(SQL);
        oracleStmt = (OraclePreparedStatement) stmt;
        oracleStmt.setRowPrefetch(10);
        {

            stmt.setInt(1, 327);
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {

            }

            rs.close();

            //oracleStmt.clearDefines();
        }
        for (int i = 0; i < 10; ++i){
            OracleUtils.enterImplicitCache(oracleStmt);
            OracleUtils.exitImplicitCacheToActive(oracleStmt);
            stmt.setInt(1, 327);
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {
               
            }
           
            rs.close();
           
        }
       
        oracleStmt.setRowPrefetch(1000);
        {
            stmt.setInt(1, 11);
            ResultSet rs = stmt.executeQuery();
            rs.next();
View Full Code Here

Examples of oracle.jdbc.internal.OraclePreparedStatement

    public static OraclePreparedStatement unwrapInternal(PreparedStatement stmt) throws SQLException {
        if (stmt instanceof OraclePreparedStatement) {
            return (OraclePreparedStatement) stmt;
        }

        OraclePreparedStatement unwrapped = stmt.unwrap(OraclePreparedStatement.class);

        if (unwrapped == null) {
            LOG.error("can not unwrap statement : " + stmt.getClass());
        }
View Full Code Here

Examples of oracle.jdbc.internal.OraclePreparedStatement

    public static OraclePreparedStatement unwrapInternal(PreparedStatement stmt) throws SQLException {
        if (stmt instanceof OraclePreparedStatement) {
            return (OraclePreparedStatement) stmt;
        }

        OraclePreparedStatement unwrapped = stmt.unwrap(OraclePreparedStatement.class);

        if (unwrapped == null) {
            LOG.error("can not unwrap statement : " + stmt.getClass());
        }
View Full Code Here

Examples of oracle.jdbc.internal.OraclePreparedStatement

    public void test_oracle() throws Exception {

        String sql = "SELECT 1";

        OracleConnection oracleConn;
        OraclePreparedStatement oracleStmt;
        PreparedStatementHolder stmtHolder;
        {
            Connection conn = dataSource.getConnection();

            {
                oracleConn = conn.unwrap(OracleConnection.class);
                Assert.assertEquals(50, oracleConn.getDefaultRowPrefetch());
            }

            PreparedStatement stmt = conn.prepareStatement(sql);

            oracleStmt = stmt.unwrap(OraclePreparedStatement.class);
            Assert.assertEquals(50, oracleStmt.getRowPrefetch());
           
            Assert.assertTrue(stmt.isWrapperFor(PreparedStatementHolder.class));
            stmtHolder = stmt.unwrap(PreparedStatementHolder.class);
            Assert.assertNotNull(stmtHolder);
            Assert.assertEquals(0, stmtHolder.getHitCount());

            ResultSet rs = stmt.executeQuery();
            rs.next();

            rs.close();
            stmt.close();
            conn.close();
        }

        {
            Connection conn = dataSource.getConnection();

            {
                OracleConnection oracleConn2 = conn.unwrap(OracleConnection.class);
                Assert.assertEquals(50, oracleConn2.getDefaultRowPrefetch());
                Assert.assertSame(oracleConn, oracleConn2);
            }

            PreparedStatement stmt = conn.prepareStatement(sql);
           
            {
                PreparedStatementHolder stmtHolder2 = stmt.unwrap(PreparedStatementHolder.class);
                Assert.assertSame(stmtHolder2, stmtHolder);
                Assert.assertEquals(1, stmtHolder.getHitCount());
            }

            ResultSet rs = stmt.executeQuery();
            rs.next();
            rs.close();
            stmt.close();
            {
                OraclePreparedStatement oracleStmt2 = stmt.unwrap(OraclePreparedStatement.class);
                Assert.assertSame(oracleStmt, oracleStmt2);
                Assert.assertEquals(2, oracleStmt.getRowPrefetch());
            }

            conn.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.