|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager
public class ConnectionRecoveryManager
This class provides methods to get a database connection and to execute SQL statements.
It also contains reconnection logic. If the connection has been closed with the
close()
method, then a call to any public method except for
setAutoReconnect(boolean)
will try to reestablish the connection, but
only if the autoReconnect
equals true
.
close()
when they encounter an SQLException.
Nested Class Summary | |
---|---|
static class |
ConnectionRecoveryManager.StreamWrapper
A wrapper for a binary stream that includes the size of the stream. |
Field Summary | |
---|---|
static int |
TRIALS
Number of reconnection attempts per method call. |
Constructor Summary | |
---|---|
ConnectionRecoveryManager(boolean block,
String driver,
String url,
String user,
String password)
Creates a ConnectionRecoveryManager and establishes
a database Connection using the driver, user, password and url
arguments. |
Method Summary | |
---|---|
void |
close()
Closes all resources held by this ConnectionRecoveryManager . |
ResultSet |
executeQuery(String sql)
Executes the given SQL query. |
PreparedStatement |
executeStmt(String sql,
Object[] params)
Executes the given SQL statement with the specified parameters. |
PreparedStatement |
executeStmt(String sql,
Object[] params,
boolean returnGeneratedKeys,
int maxRows)
Executes the given SQL statement with the specified parameters. |
Connection |
getConnection()
Gets the database connection that is managed. |
void |
setAutoReconnect(boolean autoReconnect)
Starts a transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRIALS
block == false
.
Constructor Detail |
---|
public ConnectionRecoveryManager(boolean block, String driver, String url, String user, String password) throws RepositoryException
ConnectionRecoveryManager
and establishes
a database Connection using the driver, user, password and url
arguments.
By default, the connection is in auto-commit mode, and this
manager tries to reconnect if the connection is lost.
block
- whether this class should block until the connection can be recovereddriver
- the driver to use for the connectionurl
- the url to use for the connectionuser
- the user to use for the connectionpassword
- the password to use for the connection
RepositoryException
- if the database driver could not be loadedMethod Detail |
---|
public Connection getConnection() throws SQLException, RepositoryException
SQLException
- on error
RepositoryException
- if the database driver could not be loadedpublic void setAutoReconnect(boolean autoReconnect)
endTransaction
.
SQLException
- on errorpublic ResultSet executeQuery(String sql) throws SQLException, RepositoryException
block
parameter has been set to true on construction)
if this fails and autoReconnect is enabled.
sql
- the SQL query to execute
SQLException
- on error
RepositoryException
- if the database driver could not be loadedpublic PreparedStatement executeStmt(String sql, Object[] params) throws SQLException, RepositoryException
sql
- statement to executeparams
- parameters to set
Statement
object that had been executed
SQLException
- if an error occurs
RepositoryException
- if the database driver could not be loadedpublic PreparedStatement executeStmt(String sql, Object[] params, boolean returnGeneratedKeys, int maxRows) throws SQLException, RepositoryException
sql
- statement to executeparams
- parameters to setreturnGeneratedKeys
- if the statement should return auto generated keysmaxRows
- the maximum number of rows to return (0 for all rows)
Statement
object that had been executed
SQLException
- if an error occurs
RepositoryException
- if the database driver could not be loadedpublic void close()
ConnectionRecoveryManager
.
An ongoing transaction is discarded.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |