Connection interface

The Connection interface establishes a connection (session) with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.

A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the getMetaData method.

java.sql package

public interface Connection

Tabulka 97 lists the methods in the Connection interface that are supported by DB2 Everyplace.

Tabulka 97. Connection interface methods

Method return value type Method
void clearWarnings() Clears all warnings reported for this Connection object.
void close() Releases a Connection's database and JDBC resources immediately instead of waiting for them to be automatically released.
void commit() Makes all changes made since the previous commit or rollback permanent and releases any database locks currently held by the Connection.
Statement createStatement() Creates a Statement object for sending SQL statements to the database.
Statement createStatement(int resultSetType, int resultSetConcurrency) JDBC 2.0. Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
boolean isClosed() Tests to see if a Connection is closed.
DatabaseMetaData getMetaData() Gets the metadata regarding this Connection's database.
SQLWarning getWarnings() Returns the first warning reported by calls on this Connection.
CallableStatement prepareCall(String sql) Creates a CallableStatement object for calling database stored procedures.
PreparedStatement prepareStatement (String sql) Creates a PreparedStatement object for sending parameterized SQL statements to the database.
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) JDBC 2.0. Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
void rollback() Drops all changes made since the previous commit or rollback and releases any database locks currently held by this Connection.
void setAutoCommit (boolean autoCommit) Sets this connection's auto-commit mode.

Související úlohy

Související odkazy