コード例 #1
0
ファイル: JdbcStatement.java プロジェクト: hzmmzl/afn
 /**
  * Executes an arbitrary statement. If another result set exists for this statement, this will be
  * closed (even if this statement fails).
  *
  * <p>If the statement is a create or drop and does not throw an exception, the current
  * transaction (if any) is committed after executing the statement. If auto commit is on, and the
  * statement is not a select, this statement will be committed.
  *
  * @param sql the SQL statement to execute
  * @return true if a result set is available, false if not
  */
 public boolean execute(String sql) throws SQLException {
   try {
     int id = getNextId(TraceObject.RESULT_SET);
     if (isDebugEnabled()) {
       debugCodeCall("execute", sql);
     }
     checkClosedForWrite();
     closeOldResultSet();
     sql = conn.translateSQL(sql, escapeProcessing);
     CommandInterface command = conn.prepareCommand(sql, fetchSize);
     boolean returnsResultSet;
     synchronized (session) {
       setExecutingStatement(command);
       try {
         if (command.isQuery()) {
           returnsResultSet = true;
           boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY;
           boolean updatable = resultSetConcurrency == ResultSet.CONCUR_UPDATABLE;
           ResultInterface result = command.executeQuery(maxRows, scrollable);
           resultSet =
               new JdbcResultSet(conn, this, result, id, closedByResultSet, scrollable, updatable);
         } else {
           returnsResultSet = false;
           updateCount = command.executeUpdate();
         }
       } finally {
         setExecutingStatement(null);
       }
     }
     command.close();
     return returnsResultSet;
   } catch (Exception e) {
     throw logAndConvert(e);
   }
 }