|
|||||||||
| Home >> All >> java >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.sql
Interface Connection

- public interface Connection
This interface provides methods for managing a connection to a database.
| Field Summary | |
static int |
TRANSACTION_NONE
This transaction isolation level indicates that transactions are not supported. |
static int |
TRANSACTION_READ_COMMITTED
This transaction isolation level indicates that only committed data from other transactions will be read. |
static 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. |
static int |
TRANSACTION_REPEATABLE_READ
This transaction isolation level indicates that only committed data from other transactions will be read. |
static int |
TRANSACTION_SERIALIZABLE
This transaction isolation level indicates that only committed data from other transactions will be read. |
| Method Summary | |
void |
clearWarnings()
This method clears all warnings that have occurred on this connection. |
void |
close()
This method immediately closes this database connection. |
void |
commit()
This method commits any SQL statements executed on this connection since the last commit or rollback. |
Statement |
createStatement()
This method creates a new SQL statement. |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
This method creates a new SQL statement with the specified type and concurrency. |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
This method creates a new SQL statement with the specified type, concurrency and holdability, instead of using the defaults. |
boolean |
getAutoCommit()
This method tests whether or not auto commit mode is currently enabled. |
java.lang.String |
getCatalog()
This method returns the name of the catalog in use by this connection, if any. |
int |
getHoldability()
Gets the default holdability of ResultSetS that are created
from StatementS using this Connection. |
DatabaseMetaData |
getMetaData()
This method returns the meta data for this database connection. |
int |
getTransactionIsolation()
This method returns the current transaction isolation mode. |
java.util.Map |
getTypeMap()
This method returns the mapping of SQL types to Java classes currently in use by this connection. |
SQLWarning |
getWarnings()
This method returns the first warning that occurred on this connection, if any. |
boolean |
isClosed()
This method tests whether or not this connection has been closed. |
boolean |
isReadOnly()
This method tests whether or not this connection is in read only mode. |
java.lang.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. |
CallableStatement |
prepareCall(java.lang.String sql)
This method creates a new CallableStatement for the
specified SQL string. |
CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
This method creates a new CallableStatement for the
specified SQL string. |
CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
This method creates a new CallableStatement for the
specified SQL string. |
PreparedStatement |
prepareStatement(java.lang.String sql)
This method creates a new PreparedStatement for the specified
SQL string. |
PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
|
PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
|
PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
This method creates a new PreparedStatement for the specified
SQL string. |
PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
This method creates a new PreparedStatement for the specified
SQL string. |
PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
|
void |
releaseSavepoint(Savepoint savepoint)
Removes the specified savepoint from this Connection. |
void |
rollback()
This method rolls back any SQL statements executed on this connection since the last commit or rollback. |
void |
rollback(Savepoint savepoint)
Undoes all changes made after the specified savepoint was set. |
void |
setAutoCommit(boolean autoCommit)
This method turns auto commit mode on or off. |
void |
setCatalog(java.lang.String catalog)
This method sets the name of the catalog in use by this connection. |
void |
setHoldability(int holdability)
Sets the default holdability of ResultSetS that are created
from StatementS using this Connection. |
void |
setReadOnly(boolean readOnly)
This method turns read only mode on or off. |
Savepoint |
setSavepoint()
Creates a new unnamed savepoint for this Connection |
Savepoint |
setSavepoint(java.lang.String name)
Creates a new savepoint with the specifiend name for this Connection. |
void |
setTransactionIsolation(int level)
This method sets the current transaction isolation mode. |
void |
setTypeMap(java.util.Map map)
This method sets the mapping table for SQL types to Java classes. |
| Field Detail |
TRANSACTION_NONE
public static final int TRANSACTION_NONE
- This transaction isolation level indicates that transactions are not
supported.
- See Also:
- Constant Field Values
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.
- See Also:
- Constant Field Values
TRANSACTION_READ_COMMITTED
public static final int TRANSACTION_READ_COMMITTED
- This transaction isolation level 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.
- See Also:
- Constant Field Values
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.
- See Also:
- Constant Field Values
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.
- See Also:
- Constant Field Values
| Method Detail |
createStatement
public Statement createStatement() throws SQLException
- This method creates a new SQL statement. The default result set type
and concurrency will be used.
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql) throws SQLException
- This method creates a new
PreparedStatementfor the specified SQL string. This method is designed for use with parameterized statements. The default result set type and concurrency will be used.
prepareCall
public CallableStatement prepareCall(java.lang.String sql) throws SQLException
- This method creates a new
CallableStatementfor the specified SQL string. Thie method is designed to be used with stored procedures. The default result set type and concurrency will be used.
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws SQLException
- This method converts the specified generic SQL statement into the
native grammer of the database this object is connected to.
setAutoCommit
public void setAutoCommit(boolean autoCommit)
throws SQLException
- 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.
getAutoCommit
public boolean getAutoCommit()
throws SQLException
- 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.
commit
public void commit()
throws SQLException
- This method commits any SQL statements executed on this connection since
the last commit or rollback.
rollback
public void rollback()
throws SQLException
- This method rolls back any SQL statements executed on this connection
since the last commit or rollback.
close
public void close()
throws SQLException
- This method immediately closes this database connection.
isClosed
public boolean isClosed()
throws SQLException
- This method tests whether or not this connection has been closed.
getMetaData
public DatabaseMetaData getMetaData() throws SQLException
- This method returns the meta data for this database connection.
setReadOnly
public void setReadOnly(boolean readOnly)
throws SQLException
- This method turns read only mode on or off. It may not be called while
a transaction is in progress.
isReadOnly
public boolean isReadOnly()
throws SQLException
- This method tests whether or not this connection is in read only mode.
setCatalog
public void setCatalog(java.lang.String catalog) throws SQLException
- 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.
getCatalog
public java.lang.String getCatalog() throws SQLException
- This method returns the name of the catalog in use by this connection,
if any.
setTransactionIsolation
public void setTransactionIsolation(int level)
throws SQLException
- This method sets the current transaction isolation mode. This must
be one of the constants defined in this interface.
getTransactionIsolation
public int getTransactionIsolation()
throws SQLException
- This method returns the current transaction isolation mode. This will
be one of the constants defined in this interface.
getWarnings
public SQLWarning getWarnings() throws SQLException
- 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.
clearWarnings
public void clearWarnings()
throws SQLException
- This method clears all warnings that have occurred on this connection.
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- This method creates a new SQL statement with the specified type and
concurrency. Valid values for these parameters are specified in the
ResultSetclass.
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- This method creates a new
PreparedStatementfor 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 theResultSetclass.
prepareCall
public CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- This method creates a new
CallableStatementfor 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 theResultSetclass.
getTypeMap
public java.util.Map getTypeMap() throws SQLException
- 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.
setTypeMap
public void setTypeMap(java.util.Map map) throws SQLException
- This method sets the mapping table for SQL types to Java classes.
Any entries in this map override the defaults.
setHoldability
public void setHoldability(int holdability)
throws SQLException
- Sets the default holdability of
ResultSetS that are created fromStatementS using thisConnection.- Since:
- 1.4
getHoldability
public int getHoldability()
throws SQLException
- Gets the default holdability of
ResultSetS that are created fromStatementS using thisConnection.- Since:
- 1.4
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Creates a new unnamed savepoint for this
Connection- Since:
- 1.4
setSavepoint
public Savepoint setSavepoint(java.lang.String name) throws SQLException
- Creates a new savepoint with the specifiend name for this
Connection.- Since:
- 1.4
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Undoes all changes made after the specified savepoint was set.
- Since:
- 1.4
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Removes the specified savepoint from this
Connection. Refering to a savepoint after it was removed is an error and will throw an SQLException.- Since:
- 1.4
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- This method creates a new SQL statement with the specified type,
concurrency and holdability, instead of using the defaults. Valid values
for these parameters are specified in the
ResultSetclass.- Since:
- 1.4
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- This method creates a new
PreparedStatementfor the specified SQL string. This method is designed for use with parameterized statements. The specified result set type, concurrency and holdability will be used. Valid values for these parameters are specified in theResultSetclass.- Since:
- 1.4
prepareCall
public CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- This method creates a new
CallableStatementfor the specified SQL string. Thie method is designed to be used with stored procedures. The specified result set type, concurrency and holdability will be used. Valid values for these parameters are specified in theResultSetclass.- Since:
- 1.4
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws SQLException
- Since:
- 1.4
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws SQLException
- Since:
- 1.4
prepareStatement
public PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws SQLException
- Since:
- 1.4
|
|||||||||
| Home >> All >> java >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC