Slide 12.6: Opening a connection to a database
Slide 12.8: Executing a query
Home

Creating a Statement Object


Once you connect to the database and, in the process, create your 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.

When the 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.

Few comments about this command: