The most commonly used SQL statement is the SELECT statement. We can execute SELECT statements using either a Statement or a PreparedStatement object. Both Statement and PreparedStatement have a method, executeQuery(), that executes an SQL SELECT command and returns a ResultSet containing the results of the query in the form of a table. Consider this query using Statement:
Statement stmt = new conn.getStatement(); ResultSet rs = stmt.executeQuery( "SELECT ENAME, JOB, SAL FROM EMP");
The ResultSet that this example returns contains three columns, ENAME, JOB, and SAL, as specified in the select list. Assuming the database hasn't been altered since Oracle was installed, it will contain 14 rows.
We access ...