Statement
interface:
ResultSet
object.
It is for any SQL calls that expect to return data from the database; e.g.,
ResultSet rset = stmt.executeQuery( "SELECT ename FROM emp WHERE eid='7772413'" );
INSERT
, UPDATE
, or DELETE
statement.
In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
This method returns the number of affected rows; e.g.,
stmt.executeUpdate( "INSERT INTO customers VALUES( 'Pokemon', '123456789', 0 )" );
try { stmt.execute( "DROP TABLE people" ); stmt.execute( "DROP TYPE person FORCE" ); stmt.execute( "DROP TYPE address FORCE" ); } catch( SQLException e ) { System.out.println( e ); }†This usually happens when the application is executing dynamically created SQL statements.
SQLException
provides information on a database access error or other errors.
“Why do they lock gas station bathrooms? Are they afraid someone will clean them?” – George Carlin |