Class JDBCUtils


  • public class JDBCUtils
    extends Object
    Helper for common JDBC-related operations.
    Since:
    7.3
    • Field Detail

      • MAX_TRIES

        public static final int MAX_TRIES
        Maximum number of times we retry a call if the server says it's overloaded.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JDBCUtils

        public JDBCUtils()
    • Method Detail

      • callWithRetry

        public static <V> V callWithRetry​(Callable<V> callable)
                                   throws SQLException
        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 a Connection through the DriverManager even when the server is overloaded.
        Parameters:
        url - a database url of the form jdbc:subprotocol:subname
        user - the database user on whose behalf the connection is being made
        password - the user's password
        Returns:
        a connection to the URL
        Throws:
        SQLException