Slide 12.6: Opening a connection to a database Slide 12.8: Executing a query Home |
Statement
Object
Connection
object, the next step is to create a Statement
object.
The createStatement( )
method of your JDBC Connection
object returns an object of the JDBC Statement
interface.
Below is an example of how to create the Statement
object:
Statement stmt = conn.createStatement( );Note that there is nothing Oracle-specific about this statement; it follows standard JDBC syntax.
Connection
object first gets created, it is simply a direct link to the database.
You use a Connection
object to generate implementations of java.sql.Statement
tied to the same database transaction.
java.sql.Statement
contains methods to execute SQL statements directly against the database and to obtain the results.
Statement
objects.
If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement
object.
ResultSet
object per Statement
object can be open at any point in time.
Therefore, if the reading of one ResultSet
object is interleaved with the reading of another, each must have been generated by different Statement
objects.
ResultSet
object if an open one exists.