티스토리 뷰

☠️ Java

java.sql-executeQuery, executeUpdate

James Wetzel 2024. 8. 29. 15:41
728x90
반응형

 

executeQuery

"executeQuery"는 select 쿼리문에서 사용한다.

ResultSet executeQuery()
                throws SQLException
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
Returns:
a ResultSet object that contains the data produced by the query; never null
Throws:
SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement does not return a ResultSet object
SQLTimeoutException - when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

 

 

executeUpdate

"executeUpdate"는 insert, update, delate 쿼리문에서 사용한다.

int executeUpdate()
           throws SQLException
Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement returns a ResultSet object
SQLTimeoutException - when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement
728x90
반응형