Statement.execute(sql) vs executeUpdate(sql) and executeQuery(sql)

前端 未结 3 1899
独厮守ぢ
独厮守ぢ 2020-12-14 16:03

I have a question related to this method: st.execute(sql); where st obviously is a Statement object. Directly from this oracle java tutorial:

3条回答
  •  北海茫月
    2020-12-14 16:20

    boolean execute(): Executes the SQL statement in this Prepared Statement object, which may be any kind of SQL statement.

    ResultSet executeQuery(): Executes the SQL query in this Prepared Statement object and returns the ResultSet object generated by the query.

    int executeUpdate(): Executes the SQL statement in this Prepared Statement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.

    The best place to find answers to questions like this is the Javadocs: Here

提交回复
热议问题