O'Reilly logo

Java Enterprise in a Nutshell, Second Edition by David Flanagan, Jim Farley, William Crawford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required