Java - SQL Package:: Statement Interface
Java - SQL Package:: Statement Interface
Java - SQL Package:: Statement Interface
sql package:
Statement Interface
Statement objects are returned by the createStatement() method of Connection. The execute(),
executeUpdate(), and executeQuery() methods each take a Stringparameter that contains a SQL statement.
execute() returns a boolean value that indicates whether a ResultSet is available. The ResultSet can then be
retrieved with getResultSet(). executeUpdate() returns an update count and is used for INSERT, UPDATE,
DELETE, and other data manipulation statements. executeQuery() is used for SELECTstatements, so it
returns a ResultSet. There can be only one ResultSet active per query; the current ResultSet is closed when a
new SQL statement of any kind is executed
ResultSet Interface
ResultSet objects are usually generated by the executeQuery() methods of Statement and PreparedStatement.
ResultSet allows you to scroll navigate through the data once from beginning to end, iterating through rows
using the next() method and retrieving individual fields using the getXXX() methods. The getMetaData()
method returns a ResultSetMetaData object that describes the structure of the underlying data.