20230628 java.sql.Statement

发布时间 2023-08-28 09:53:43作者: 流星<。)#)))≦

介绍

  • java.sql.Statement
  • public interface Statement extends Wrapper, AutoCloseable
  • 语句

API

常量

  • SUCCESS_NO_INFO : -2
  • EXECUTE_FAILED : -3

getMoreResults

  • CLOSE_CURRENT_RESULT : 1
  • KEEP_CURRENT_RESULT : 2
  • CLOSE_ALL_RESULTS : 3

autoGeneratedKeys

  • RETURN_GENERATED_KEYS : 1
    • 返回自动生成的键
  • NO_GENERATED_KEYS : 2
    • 不返回自动生成的键

public

  • cancel

    • 取消执行
  • closeOnCompletion

    • 关联的结果集被关闭后,立刻关闭
  • isCloseOnCompletion

  • addBatch

  • clearBatch

  • close

  • isClosed

  • getConnection

    • Connection
  • isSimpleIdentifier

  • setCursorName

  • setEscapeProcessing

  • setFetchDirection, getFetchDirection

  • setFetchSize, getFetchSize

  • setMaxFieldSize, getMaxFieldSize

  • setMaxRows, getMaxRows, setLargeMaxRows, getLargeMaxRows

  • setPoolable, isPoolable

  • setQueryTimeout, getQueryTimeout

  • enquoteIdentifier

  • enquoteLiteral

  • enquoteNCharLiteral

  • getWarnings

  • clearWarnings

execute

  • execute
    • boolean execute(String sql) throws SQLException;
    • execute 方法执行一条SQL语句并指示第一个结果的形式。然后,您必须使用 getResultSetgetUpdateCount 方法来检索结果,并使用 getMoreResults 来移动到任何后续结果
    • 如果第一个结果是 ResultSet 对象,返回 true ;如果是更新计数或没有结果, 返回 false
  • executeQuery
    • ResultSet executeQuery(String sql) throws SQLException;
  • executeUpdate, executeLargeUpdate
    • int executeUpdate(String sql) throws SQLException;
  • executeBatch, executeLargeBatch
    • int[] executeBatch() throws SQLException;
    • 返回值不同,executeBatch 返回 int,executeLargeBatch 返回 long

getResult

  • getResultSet
  • getResultSetConcurrency
  • getResultSetHoldability
  • getResultSetType
  • getUpdateCount, getLargeUpdateCount
  • getMoreResults
    • 获取该语句的下一个结果集
    • 如果存在下一个结果集,则返回 true
    • 调用存储过程可能返回多个结果集
  • getGeneratedKeys
    • ResultSet getGeneratedKeys() throws SQLException;
    • 获取自动生成键