Name

Connection

Synopsis

The Connection interface represents an individual database connection. The object includes factory methods for Statement, PreparedStatement and CallableStatement objects and a number of transaction control methods (setAutoCommit(), commit(), rollback(), getAutoCommit(), setTransactionIsolation(), getTransactionIsolation()). Other methods provide information about the database. The most important of these is getMetaData(), which returns a DatabaseMetaData object. The getWarnings() method returns any warnings pending for this connection.

Connection objects are created with the static DriverManager.getConnection() method. Newly created connections are in auto-commit mode by default, and use the default type map for mapping database entities to Java objects. The setTypeMap() method can be used to create a new type mapping for custom data types. JDBC 3.0 introduces support for savepoints through the Connection and Savepoint interfaces.

public interface Connection {
// Public Constants
   public static final int TRANSACTION_NONE;                     // =0
   public static final int TRANSACTION_READ_COMMITTED;           // =2
   public static final int TRANSACTION_READ_UNCOMMITTED;         // =1
   public static final int TRANSACTION_REPEATABLE_READ;          // =4
   public static final int TRANSACTION_SERIALIZABLE;             // =8
                  // Property Accessor Methods (by property name)
   public abstract boolean getAutoCommit(
        ) throws SQLException;  
   public abstract void setAutoCommit(
        boolean autoCommit) throws SQLException; public abstract String ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.