Recent Pos

The JDBC Statement execute() method

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

jdbc statement execute method sql editor
⇒ In addition to the executeUpdate() and executeQuery() two specialized methods in the JDBC Statement, we have a execute() method with the following signature:

⇒ This can take any (i.e. SELECT and non-SELECT) query to execute.

⇒ This method throws SQLException in case if there is any error in executing the given SQL statment.

⇒ This returns true if the given SQL statement is a SELECT statement generating the ResultSet otherwise false.

⇒ The following two methods of Statement object can support for getting the ResultSet:

⇒ This will return the no. of records effected executing the SQL. This method can be used in case of execute() method returning false.
 

⇒ This is used to get the ResultSet in case if the execute() method return true.
 
Example:

 

SQLEditor.java

 
Note: Use the ConnectionFactory.java, jdbc.properties from previous example
 
Download this example: SQLEditor-execute.zip
 
 
<-Previous: Value Object or Data Transfer Object (DTO) design pattern | | Next->The JDBC PreparedStatement Object

No Comments

Post a Comment