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:- Aaron M. Renn (arenn@urbanophile.com)
void | clearWarnings()
|
void | close()
|
void | commit()
|
java.sql.Statement | createStatement()
|
java.sql.Statement | createStatement(int resultSetType, int resultSetConcurrency)
|
java.sql.Statement | createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
boolean | getAutoCommit()
|
java.lang.String | getCatalog()
|
int | getHoldability()
|
java.sql.DatabaseMetaData | getMetaData()
|
int | getTransactionIsolation()
|
java.util.Map | getTypeMap()
|
java.sql.SQLWarning | getWarnings()
|
boolean | isClosed()
|
boolean | isReadOnly()
|
java.lang.String | nativeSQL(java.lang.String sql)
|
java.sql.CallableStatement | prepareCall(java.lang.String sql)
|
java.sql.CallableStatement | prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
|
java.sql.CallableStatement | prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int autoGeneratedKeys)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int[] columnIndexes)
|
java.sql.PreparedStatement | prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
|
void | releaseSavepoint(java.sql.Savepoint savepoint)
|
void | rollback()
|
void | rollback(java.sql.Savepoint savepoint)
|
void | setAutoCommit(boolean autoCommit)
|
void | setCatalog(java.lang.String catalog)
|
void | setHoldability(int holdability)
|
void | setReadOnly(boolean readOnly)
|
java.sql.Savepoint | setSavepoint()
|
java.sql.Savepoint | setSavepoint(java.lang.String name)
|
void | setTransactionIsolation(int level)
|
void | setTypeMap(java.util.Map map)
|
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.
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:
true
if auto commit mode is enabled,
false
otherwise.
Throws:
See Also:
getCatalog
public String getCatalog()
This method returns the name of the catalog in use by this connection,
if any.
Returns:
- The name of the catalog, or
null
if one does not
exist or catalogs are not supported by this database.
Throws:
getHoldability
public int getHoldability()
Since:
getMetaData
public DatabaseMetaData getMetaData()
This method returns the meta data for this database connection.
Returns:
- The meta data for this database.
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:
- The transaction isolation level.
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:
- The SQL type to Java class mapping.
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:
- The first
SQLWarning
that occurred, or
null
if there have been no warnings.
Throws:
isClosed
public boolean isClosed()
This method tests whether or not this connection has been closed.
Returns:
true
if the connection is closed, false
otherwise.
Throws:
isReadOnly
public boolean isReadOnly()
This method tests whether or not this connection is in read only mode.
Returns:
true
if the connection is read only false
otherwise.
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:
- The native SQL statement.
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: