public class ConnectionManager extends Object
Title: 常用代码打包
Description: Central manager of database connections. All methods are static so that they can be easily accessed throughout the classes in the database package.
This class also provides a set of utility methods that abstract out operations that may not work on all databases such as setting the max number or rows that a query should return.
Copyright: Copyright (c) 2006
Company: www.justdos.net
ConnectionProvider| 限定符和类型 | 字段和说明 |
|---|---|
ProviderConfig |
providerConfig |
| 限定符 | 构造器和说明 |
|---|---|
protected |
ConnectionManager(ProviderConfig providerConfig) |
protected |
ConnectionManager(String configKey) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
clearRecordedConnection() |
void |
closeTransactionConnection(Connection con,
boolean abortTransaction)
Closes a Connection.
|
PreparedStatement |
createScrollablePreparedStatement(Connection con,
String sql)
Creates a scroll insensitive PreparedStatement if the JDBC driver supports it, or a normal PreparedStatement
otherwise.
|
Statement |
createScrollableStatement(Connection con)
Creates a scroll insensitive Statement if the JDBC driver supports it, or a normal Statement otherwise.
|
void |
destroy()
Proxy method for ConnectionProvider
|
Connection |
getConnection()
Returns a database connection from the currently active connection provider.
|
ConnectionProvider |
getConnectionProvider()
Returns the current connection provider.
|
String |
getLargeTextField(ResultSet rs,
int columnIndex)
Retrives a large text column from a result set, automatically performing streaming if the JDBC driver requires
it.
|
List |
getRecordedConnction() |
Connection |
getTransactionConnection()
Returns a Connection from the currently active connection provider that is ready to participate in transactions
(auto commit is set to false).
|
boolean |
isBatchUpdatesSupported() |
boolean |
isFetchSizeSupported() |
boolean |
isMaxRowsSupported() |
boolean |
isPooled()
Proxy method for ConnectionProvider
|
boolean |
isProfilingEnabled()
Returns true if connection profiling is turned on.
|
boolean |
isRecordConnectionEnabled() |
boolean |
isScrollResultsSupported() |
boolean |
isStreamTextRequired() |
boolean |
isSubqueriesSupported() |
boolean |
isTransactionsSupported() |
void |
restart()
Proxy method for ConnectionProvider
|
void |
scrollResultSet(ResultSet rs,
int rowNumber)
Scrolls forward in a result set to the specified row number.
|
void |
setConnectionProvider(ConnectionProvider provider)
Sets the connection provider.
|
void |
setFetchSize(ResultSet rs,
int fetchSize)
Sets the number of rows that the JDBC driver should buffer at a time.
|
void |
setLargeTextField(PreparedStatement pstmt,
int parameterIndex,
String value)
Sets a large text column in a result set, automatically performing streaming if the JDBC driver requires it.
|
void |
setMaxRows(Statement stmt,
int maxRows)
Sets the max number of rows that should be returned from executing a statement.
|
void |
setProfilingEnabled(boolean enable)
Turns connection profiling on or off.
|
void |
setRecordConnectionEnabled(boolean recordConnectionEnabled) |
void |
start()
Proxy method for ConnectionProvider
|
public ProviderConfig providerConfig
protected ConnectionManager(String configKey)
protected ConnectionManager(ProviderConfig providerConfig)
public Connection getConnection() throws SQLException
SQLExceptionpublic List getRecordedConnction()
public void clearRecordedConnection()
public Connection getTransactionConnection() throws SQLException
SQLExceptionpublic void closeTransactionConnection(Connection con, boolean abortTransaction)
abortTransaction.public Statement createScrollableStatement(Connection con) throws SQLException
con - the database connection.SQLException - if an error occurs.public PreparedStatement createScrollablePreparedStatement(Connection con, String sql) throws SQLException
con - the database connection.sql - the SQL to create the PreparedStatement with.SQLException - if an error occurs.public void scrollResultSet(ResultSet rs, int rowNumber) throws SQLException
rs - the ResultSet object to scroll.rowNumber - the row number to scroll forward to.SQLException - if an error occurs.public ConnectionProvider getConnectionProvider()
public void setConnectionProvider(ConnectionProvider provider)
provider - the ConnectionProvider that the manager should obtain connections from.public String getLargeTextField(ResultSet rs, int columnIndex) throws SQLException
rs - the ResultSet to retrieve the text field from.columnIndex - the column in the ResultSet of the text field.SQLExceptionpublic void setLargeTextField(PreparedStatement pstmt, int parameterIndex, String value) throws SQLException
pstmt - the PreparedStatement to set the text field in.parameterIndex - the index corresponding to the text field.value - the String to set.SQLExceptionpublic void setMaxRows(Statement stmt, int maxRows)
stmt - the Statement to set the max number of rows for.maxRows - the max number of rows to return.public void setFetchSize(ResultSet rs, int fetchSize)
rs - the ResultSet to set the fetch size for.fetchSize - the fetchSize.public boolean isProfilingEnabled()
public boolean isTransactionsSupported()
public boolean isStreamTextRequired()
public boolean isMaxRowsSupported()
public boolean isFetchSizeSupported()
public boolean isSubqueriesSupported()
public boolean isScrollResultsSupported()
public boolean isBatchUpdatesSupported()
public boolean isPooled()
ConnectionProviderpublic void start()
ConnectionProviderpublic void restart()
ConnectionProviderpublic void destroy()
ConnectionProviderpublic boolean isRecordConnectionEnabled()
public void setRecordConnectionEnabled(boolean recordConnectionEnabled)
recordConnectionEnabled - The recordConnectionEnabled to set.public void setProfilingEnabled(boolean enable)
enable - true to enable profiling; false to disable.Copyright © 2023 onecode. All rights reserved.