/** * Constructor for JdbcStatementResource * * @param connV a JdbcConnectionResource connection */ public JdbcPreparedStatementResource(JdbcConnectionResource conn) { super(conn); }
public JdbcStatementResource(JdbcConnectionResource conn) { _conn = conn; }
/** * Prepares this statement with the given query. * * @param query SQL query * @return true on success or false on failure */ public bool prepare(Env env, string query) { try { PreparedStatement preparedStmt = _preparedStmt; if (preparedStmt != null) { preparedStmt.close(); } setQuery(query); if (query.length() == 0) { return(false); } JdbcConnectionResource conn = getConnection(); Connection javaConn = getJavaConnection(env); if (conn == null) { return(false); } if (!isPreparable(query)) { Statement stmt = javaConn.createStatement(); setStatement(stmt); return(true); } if (getStatementType() == StatementType.INSERT) { preparedStmt = javaConn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); } else if (this instanceof OracleStatement) { preparedStmt = javaConn.prepareCall(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } else if (conn.isSeekable()) { preparedStmt = javaConn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } else { preparedStmt = javaConn.prepareStatement(query); } _preparedStmt = preparedStmt; setStatement(preparedStmt); return(true); }