Search in sources :

Example 1 with OraclePreparedStatement

use of oracle.jdbc.OraclePreparedStatement in project druid by alibaba.

the class TestOraclePreparedStatement method test_0.

public void test_0() throws Exception {
    Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
    OracleConnection oracleConn = (OracleConnection) conn;
    // ResultSet metaRs = conn.getMetaData().getTables(null, "ALIBABA", null, new String[] {"TABLE"});
    // JdbcUtils.printResultSet(metaRs);
    // metaRs.close();
    int fetchRowSize = oracleConn.getDefaultRowPrefetch();
    // {
    // oracleConn.setStatementCacheSize(10);
    // oracleConn.setImplicitCachingEnabled(true);
    // 
    // PreparedStatement stmt = conn.prepareStatement(SQL);
    // stmt.close();
    // 
    // 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();
        rs.close();
        stmt.close();
    }
    conn.close();
}
Also used : Connection(java.sql.Connection) OracleConnection(oracle.jdbc.OracleConnection) ResultSet(java.sql.ResultSet) OraclePreparedStatement(oracle.jdbc.OraclePreparedStatement) OraclePreparedStatement(oracle.jdbc.OraclePreparedStatement) PreparedStatement(java.sql.PreparedStatement) OracleConnection(oracle.jdbc.OracleConnection)

Example 2 with OraclePreparedStatement

use of oracle.jdbc.OraclePreparedStatement in project translationstudio8 by heartsome.

the class TMDatabaseImpl method insertTMXProp.

/**
	 * 将数据插入TMXPROPS表
	 * @param params
	 *            ;
	 * @throws SQLException
	 */
public void insertTMXProp(Map<String, String> params) throws SQLException {
    OraclePreparedStatement stmt = null;
    try {
        String sql = dbConfig.getOperateDbSQL("insert-tmxprops");
        stmt = (OraclePreparedStatement) conn.prepareStatement(sql);
        int i = 1;
        stmt.setString(i++, params.get("PARENTNAME"));
        stmt.setInt(i++, Integer.parseInt(params.get("PARENTID")));
        stmt.setString(i++, params.get("TYPE"));
        stmt.setString(i++, params.get("LANG"));
        stmt.setString(i++, params.get("ENCODING"));
        stmt.setStringForClob(i++, params.get("CONTENT"));
        stmt.executeUpdate();
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
}
Also used : OraclePreparedStatement(oracle.jdbc.OraclePreparedStatement)

Aggregations

OraclePreparedStatement (oracle.jdbc.OraclePreparedStatement)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 OracleConnection (oracle.jdbc.OracleConnection)1