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
FieldsModifier and TypeFieldDescriptionstatic final intMaximum number of times we retry a call if the server says it's overloaded. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> VcallWithRetry(Callable<V> callable) Tries to do a JDBC call even when the server is overloaded.static ConnectiongetConnection(String url, String user, String password) Tries to acquire aConnectionthrough theDriverManagereven when the server is overloaded.static ConnectiongetConnection(DataSource dataSource) Tries to acquire aConnectionthrough aDataSourceeven when the server is overloaded.static XAConnectiongetXAConnection(XADataSource xaDataSource) Tries to acquire aXAConnectionthrough aXADataSourceeven 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 aConnectionthrough theDriverManagereven when the server is overloaded.- Parameters:
url- a database url of the formjdbc:subprotocol:subnameuser- 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 aConnectionthrough aDataSourceeven when the server is overloaded.- Parameters:
dataSource- the data source- Returns:
- a connection to the data source
- Throws:
SQLException
-
getXAConnection
Tries to acquire aXAConnectionthrough aXADataSourceeven when the server is overloaded.- Parameters:
xaDataSource- the XA data source- Returns:
- a XA connection to the XA data source
- Throws:
SQLException
-