|
||||||||||
| 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,
java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.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. |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Executes the given SQL query. |
java.sql.PreparedStatement |
executeStmt(java.lang.String sql,
java.lang.Object[] params)
Executes the given SQL statement with the specified parameters. |
java.sql.PreparedStatement |
executeStmt(java.lang.String sql,
java.lang.Object[] params,
boolean returnGeneratedKeys,
int maxRows)
Executes the given SQL statement with the specified parameters. |
java.sql.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,
java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
throws javax.jcr.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
javax.jcr.RepositoryException - if the database driver could not be loaded| Method Detail |
|---|
public java.sql.Connection getConnection()
throws java.sql.SQLException,
javax.jcr.RepositoryException
java.sql.SQLException - on error
javax.jcr.RepositoryException - if the database driver could not be loadedpublic void setAutoReconnect(boolean autoReconnect)
endTransaction.
java.sql.SQLException - on error
public java.sql.ResultSet executeQuery(java.lang.String sql)
throws java.sql.SQLException,
javax.jcr.RepositoryException
block parameter has been set to true on construction)
if this fails and autoReconnect is enabled.
sql - the SQL query to execute
java.sql.SQLException - on error
javax.jcr.RepositoryException - if the database driver could not be loaded
public java.sql.PreparedStatement executeStmt(java.lang.String sql,
java.lang.Object[] params)
throws java.sql.SQLException,
javax.jcr.RepositoryException
sql - statement to executeparams - parameters to set
Statement object that had been executed
java.sql.SQLException - if an error occurs
javax.jcr.RepositoryException - if the database driver could not be loaded
public java.sql.PreparedStatement executeStmt(java.lang.String sql,
java.lang.Object[] params,
boolean returnGeneratedKeys,
int maxRows)
throws java.sql.SQLException,
javax.jcr.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
java.sql.SQLException - if an error occurs
javax.jcr.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 | |||||||||