|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ModSQL.Connection
A Connection represents a session with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.
Note: By default the Connection automatically commits changes after executing each statement. If auto commit has been disabled, an explicit commit must be done or database changes will not be saved.
PreparedStatement,
ResultSet,
DatabaseMetaData| Field Summary | |
protected DatabaseManager |
tablemanager
DatabaseManager to use for looking up tables. |
| Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
Connection()
Constructor. |
|
| Method Summary | |
void |
clearWarnings()
After this call, getWarnings returns null until a new warning is reported for this Connection. |
void |
close()
In some cases, it is desirable to immediately release a Connection's database and JDBC resources instead of waiting for them to be automatically released; the close method provides this immediate release. |
void |
commit()
Commit makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. |
Statement |
createStatement()
SQL statements without parameters are normally executed using Statement objects. |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden. |
boolean |
getAutoCommit()
Get the current auto-commit state. |
String |
getCatalog()
Return the Connection's current catalog name. |
DatabaseMetaData |
getMetaData()
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. |
int |
getTransactionIsolation()
Get this Connection's current transaction isolation mode. |
Map |
getTypeMap()
Not implemented. |
SQLWarning |
getWarnings()
The first warning reported by calls on this Connection is returned. |
boolean |
isClosed()
Tests to see if a Connection is closed. |
boolean |
isReadOnly()
Tests to see if the connection is in read-only mode. |
String |
nativeSQL(String sql)
A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; nativeSQL returns the native form of the statement that the driver would have sent. |
CallableStatement |
prepareCall(String sql)
A SQL stored procedure call statement is handled by creating a CallableStatement for it. |
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden. |
PreparedStatement |
prepareStatement(String sql)
A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden. |
void |
rollback()
Rollback drops all changes made since the previous commit/rollback and releases any database locks currently held by the Connection. |
void |
setAutoCommit(boolean autoCommit)
If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. |
void |
setCatalog(String catalog)
A sub-space of this Connection's database may be selected by setting a catalog name. |
void |
setReadOnly(boolean readOnly)
You can put a connection in read-only mode as a hint to enable database optimizations. |
void |
setTransactionIsolation(int level)
You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values. |
void |
setTypeMap(Map map)
Not implemented. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected DatabaseManager tablemanager
| Constructor Detail |
public Connection()
MetaManager as default DatabaseManager.| Method Detail |
public Statement createStatement()
throws SQLException
createStatement in interface ConnectionSQLException - if a database-access error occurs.
public PreparedStatement prepareStatement(String sql)
throws SQLException
Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement is executed. This has no direct affect on users; however, it does affect which method throws certain SQLExceptions.
prepareStatement in interface Connectionsql - a SQL statement that may contain one or more '?' IN
parameter placeholdersSQLException - if a database-access error occurs.
public CallableStatement prepareCall(String sql)
throws SQLException
Note: This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the prepareCall is done; others may wait until the CallableStatement is executed. This has no direct affect on users; however, it does affect which method throws certain SQLExceptions.
prepareCall in interface Connectionsql - a SQL statement that may contain one or more '?'
parameter placeholders. Typically this statement is a JDBC
function call escape string.SQLException - if a database-access error occurs.
public String nativeSQL(String sql)
throws SQLException
nativeSQL in interface Connectionsql - a SQL statement that may contain one or more '?'
parameter placeholdersSQLException - if a database-access error occurs.
public void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionautoCommit - true enables auto-commit; false disables
auto-commit.SQLException - if a database-access error occurs.
public boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLException - if a database-access error occurs.setAutoCommit(boolean)
public void commit()
throws SQLException
commit in interface ConnectionSQLException - if a database-access error occurs.setAutoCommit(boolean)
public void rollback()
throws SQLException
rollback in interface ConnectionSQLException - if a database-access error occurs.setAutoCommit(boolean)
public void close()
throws SQLException
Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.
close in interface ConnectionSQLException - if a database-access error occurs.
public boolean isClosed()
throws SQLException
isClosed in interface ConnectionSQLException - if a database-access error occurs.
public DatabaseMetaData getMetaData()
throws SQLException
getMetaData in interface ConnectionSQLException - if a database-access error occurs.
public void setReadOnly(boolean readOnly)
throws SQLException
Note: setReadOnly cannot be called while in the middle of a transaction.
setReadOnly in interface ConnectionreadOnly - true enables read-only mode; false disables
read-only mode.SQLException - if a database-access error occurs.
public boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLException - if a database-access error occurs.
public void setCatalog(String catalog)
throws SQLException
setCatalog in interface ConnectionSQLException - if a database-access error occurs.
public String getCatalog()
throws SQLException
getCatalog in interface ConnectionSQLException - if a database-access error occurs.
public void setTransactionIsolation(int level)
throws SQLException
Note: setTransactionIsolation cannot be called while in the middle of a transaction.
setTransactionIsolation in interface Connectionlevel - one of the TRANSACTION_* isolation values with the
exception of TRANSACTION_NONE; some databases may not support
other valuesSQLException - if a database-access error occurs.DatabaseMetaData.supportsTransactionIsolationLevel(int)
public int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLException - if a database-access error occurs.
public SQLWarning getWarnings()
throws SQLException
Note: Subsequent warnings will be chained to this SQLWarning.
getWarnings in interface ConnectionSQLException - if a database-access error occurs.
public void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLException - if a database-access error occurs.
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
createStatement in interface ConnectionresultSetType - a result set type, see ResultSet.TYPE_XXXresultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXXSQLException - if a database-access error occurs.
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareStatement in interface ConnectionresultSetType - a result set type, see ResultSet.TYPE_XXXresultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXXSQLException - if a database-access error occurs.
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareCall in interface ConnectionresultSetType - a result set type, see ResultSet.TYPE_XXXresultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXXSQLException - if a database-access error occurs.
public Map getTypeMap()
throws SQLException
getTypeMap in interface Connection
public void setTypeMap(Map map)
throws SQLException
setTypeMap in interface Connection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||