Package org.nuxeo.common.utils
Class JDBCUtils
java.lang.Object
org.nuxeo.common.utils.JDBCUtils
Helper for common JDBC-related operations.
- Since:
- 7.3
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Maximum number of times we retry a call if the server says it's overloaded. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> V
callWithRetry
(Callable<V> callable) Tries to do a JDBC call even when the server is overloaded.static Connection
getConnection
(String url, String user, String password) Tries to acquire aConnection
through theDriverManager
even when the server is overloaded.static Connection
getConnection
(DataSource dataSource) Tries to acquire aConnection
through aDataSource
even when the server is overloaded.static XAConnection
getXAConnection
(XADataSource xaDataSource) Tries to acquire aXAConnection
through aXADataSource
even when the server is overloaded.
-
Field Details
-
MAX_TRIES
public static final int MAX_TRIESMaximum number of times we retry a call if the server says it's overloaded.- See Also:
-
-
Constructor Details
-
JDBCUtils
public JDBCUtils()
-
-
Method Details
-
callWithRetry
Tries to do a JDBC call even when the server is overloaded.Oracle has problems opening and closing many connections in a short time span (ORA-12516, ORA-12519). It seems to have something to do with how closed sessions are not immediately accounted for by Oracle's PMON (process monitor). When we get these errors, we retry a few times with exponential backoff.
- Parameters:
callable
- the callable- Returns:
- the returned value
- Throws:
SQLException
-
getConnection
public static Connection getConnection(String url, String user, String password) throws SQLException Tries to acquire aConnection
through theDriverManager
even when the server is overloaded.- Parameters:
url
- a database url of the formjdbc:subprotocol:subname
user
- the database user on whose behalf the connection is being madepassword
- the user's password- Returns:
- a connection to the URL
- Throws:
SQLException
-
getConnection
Tries to acquire aConnection
through aDataSource
even when the server is overloaded.- Parameters:
dataSource
- the data source- Returns:
- a connection to the data source
- Throws:
SQLException
-
getXAConnection
Tries to acquire aXAConnection
through aXADataSource
even when the server is overloaded.- Parameters:
xaDataSource
- the XA data source- Returns:
- a XA connection to the XA data source
- Throws:
SQLException
-