Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.sql

Interface Connection

java.lang.Object
|
+--java.sql.Connection


public interface Connection

This interface provides methods for managing a connection to a database.

Author:

Field Summary

static intTRANSACTION_NONE

This transaction isolation level indicates that transactions are not supported.
static intTRANSACTION_READ_COMMITTED

This transaction isolation leve indicates that only committed data from other transactions will be read.
static intTRANSACTION_READ_UNCOMMITTED

This transaction isolation level indicates that one transaction can read modifications by other transactions before the other transactions have committed their changes.
static intTRANSACTION_REPEATABLE_READ

This transaction isolation level indicates that only committed data from other transactions will be read.
static intTRANSACTION_SERIALIZABLE

This transaction isolation level indicates that only committed data from other transactions will be read.

Method Summary

voidclearWarnings()

This method clears all warnings that have occurred on this connection.
voidclose()

This method immediately closes this database connection.
voidcommit()

This method commits any SQL statements executed on this connection since the last commit or rollback.
java.sql.StatementcreateStatement()

This method creates a new SQL statement.
java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency)

This method creates a new SQL statement with the specified type and concurrency.
java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)

booleangetAutoCommit()

This method tests whether or not auto commit mode is currently enabled.
java.lang.StringgetCatalog()

This method returns the name of the catalog in use by this connection, if any.
intgetHoldability()

java.sql.DatabaseMetaDatagetMetaData()

This method returns the meta data for this database connection.
intgetTransactionIsolation()

This method returns the current transaction isolation mode.
java.util.MapgetTypeMap()

This method returns the mapping of SQL types to Java classes currently in use by this connection.
java.sql.SQLWarninggetWarnings()

This method returns the first warning that occurred on this connection, if any.
booleanisClosed()

This method tests whether or not this connection has been closed.
booleanisReadOnly()

This method tests whether or not this connection is in read only mode.
java.lang.StringnativeSQL(java.lang.String sql)

This method converts the specified generic SQL statement into the native grammer of the database this object is connected to.
java.sql.CallableStatementprepareCall(java.lang.String sql)

This method creates a new CallableStatement for the specified SQL string.
java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)

This method creates a new CallableStatement for the specified SQL string.
java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

java.sql.PreparedStatementprepareStatement(java.lang.String sql)

This method creates a new PreparedStatement for the specified SQL string.
java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)

This method creates a new PreparedStatement for the specified SQL string.
java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)

java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] columnIndexes)

java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] columnNames)

voidreleaseSavepoint(java.sql.Savepoint savepoint)

voidrollback()

This method rolls back any SQL statements executed on this connection since the last commit or rollback.
voidrollback(java.sql.Savepoint savepoint)

voidsetAutoCommit(boolean autoCommit)

This method turns auto commit mode on or off.
voidsetCatalog(java.lang.String catalog)

This method sets the name of the catalog in use by this connection.
voidsetHoldability(int holdability)

voidsetReadOnly(boolean readOnly)

This method turns read only mode on or off.
java.sql.SavepointsetSavepoint()

java.sql.SavepointsetSavepoint(java.lang.String name)

voidsetTransactionIsolation(int level)

This method sets the current transaction isolation mode.
voidsetTypeMap(java.util.Map map)

This method sets the mapping table for SQL types to Java classes.

Field Details

TRANSACTION_NONE

public static final int TRANSACTION_NONE

This transaction isolation level indicates that transactions are not supported.


TRANSACTION_READ_COMMITTED

public static final int TRANSACTION_READ_COMMITTED

This transaction isolation leve indicates that only committed data from other transactions will be read. If a transaction reads a row, then another transaction commits a change to that row, the first transaction would retrieve the changed row on subsequent reads of the same row.


TRANSACTION_READ_UNCOMMITTED

public static final int TRANSACTION_READ_UNCOMMITTED

This transaction isolation level indicates that one transaction can read modifications by other transactions before the other transactions have committed their changes. This could result in invalid reads.


TRANSACTION_REPEATABLE_READ

public static final int TRANSACTION_REPEATABLE_READ

This transaction isolation level indicates that only committed data from other transactions will be read. It also ensures that data read from a row will not be different on a subsequent read even if another transaction commits a change.


TRANSACTION_SERIALIZABLE

public static final int TRANSACTION_SERIALIZABLE

This transaction isolation level indicates that only committed data from other transactions will be read. It also ensures that data read from a row will not be different on a subsequent read even if another transaction commits a change. Additionally, rows modified by other transactions will not affect the result set returned during subsequent executions of the same WHERE clause in this transaction.


Method Details

clearWarnings

public void clearWarnings()

This method clears all warnings that have occurred on this connection.

Throws:


close

public void close()

This method immediately closes this database connection.

Throws:


commit

public void commit()

This method commits any SQL statements executed on this connection since the last commit or rollback.

Throws:


createStatement

public Statement createStatement()

This method creates a new SQL statement. The default result set type and concurrency will be used.

Returns:

Throws:

See Also:


createStatement

public Statement createStatement(int resultSetType, int resultSetConcurrency)

This method creates a new SQL statement with the specified type and concurrency. Valid values for these parameters are specified in the ResultSet class.

Parameters:

Returns:

Throws:

See Also:


createStatement

public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Since:Parameters:


getAutoCommit

public boolean getAutoCommit()

This method tests whether or not auto commit mode is currently enabled. In auto commit mode, every SQL statement is committed its own transaction. Otherwise a transaction must be explicitly committed or rolled back.

Returns:

Throws:

See Also:


getCatalog

public String getCatalog()

This method returns the name of the catalog in use by this connection, if any.

Returns:

Throws:


getHoldability

public int getHoldability()

Since:

getMetaData

public DatabaseMetaData getMetaData()

This method returns the meta data for this database connection.

Returns:

Throws:

See Also:


getTransactionIsolation

public int getTransactionIsolation()

This method returns the current transaction isolation mode. This will be one of the constants defined in this interface.

Returns:

Throws:


getTypeMap

public Map getTypeMap()

This method returns the mapping of SQL types to Java classes currently in use by this connection. This mapping will have no entries unless they have been manually added.

Returns:

Throws:


getWarnings

public SQLWarning getWarnings()

This method returns the first warning that occurred on this connection, if any. If there were any subsequence warnings, they will be chained to the first one.

Returns:

Throws:


isClosed

public boolean isClosed()

This method tests whether or not this connection has been closed.

Returns:

Throws:


isReadOnly

public boolean isReadOnly()

This method tests whether or not this connection is in read only mode.

Returns:

Throws:


nativeSQL

public String nativeSQL(java.lang.String sql)

This method converts the specified generic SQL statement into the native grammer of the database this object is connected to.

Parameters:

Returns:

Throws:


prepareCall

public CallableStatement prepareCall(java.lang.String sql)

This method creates a new CallableStatement for the specified SQL string. Thie method is designed to be used with stored procedures. The default result set type and concurrency will be used.

Parameters:

Returns:

Throws:

See Also:


prepareCall

public CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)

This method creates a new CallableStatement for the specified SQL string. Thie method is designed to be used with stored procedures. The specified result set type and concurrency will be used. Valid values for these parameters are specified in the ResultSet class.

Parameters:

Returns:

Throws:

See Also:


prepareCall

public CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Since:Parameters:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql)

This method creates a new PreparedStatement for the specified SQL string. This method is designed for use with parameterized statements. The default result set type and concurrency will be used.

Parameters:

Returns:

Throws:

See Also:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys)

Since:Parameters:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes)

Since:Parameters:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)

This method creates a new PreparedStatement for the specified SQL string. This method is designed for use with parameterized statements. The specified result set type and concurrency will be used. Valid values for these parameters are specified in the ResultSet class.

Parameters:

Returns:

Throws:

See Also:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Since:Parameters:


prepareStatement

public PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames)

Since:Parameters:


releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint savepoint)

Since:Parameters:


rollback

public void rollback()

This method rolls back any SQL statements executed on this connection since the last commit or rollback.

Throws:


rollback

public void rollback(java.sql.Savepoint savepoint)

Since:Parameters:


setAutoCommit

public void setAutoCommit(boolean autoCommit)

This method turns auto commit mode on or off. In auto commit mode, every SQL statement is committed its own transaction. Otherwise a transaction must be explicitly committed or rolled back.

Parameters:

Throws:

See Also:


setCatalog

public void setCatalog(java.lang.String catalog)

This method sets the name of the catalog in use by this connection. Note that this method does nothing if catalogs are not supported by this database.

Parameters:

Throws:


setHoldability

public void setHoldability(int holdability)

Since:Parameters:


setReadOnly

public void setReadOnly(boolean readOnly)

This method turns read only mode on or off. It may not be called while a transaction is in progress.

Parameters:

Throws:


setSavepoint

public Savepoint setSavepoint()

Since:

setSavepoint

public Savepoint setSavepoint(java.lang.String name)

Since:Parameters:


setTransactionIsolation

public void setTransactionIsolation(int level)

This method sets the current transaction isolation mode. This must be one of the constants defined in this interface.

Parameters:

Throws:


setTypeMap

public void setTypeMap(java.util.Map map)

This method sets the mapping table for SQL types to Java classes. Any entries in this map override the defaults.

Parameters:

Throws: