Class JdbcUtils

java.lang.Object
migratedb.v1.core.internal.jdbc.JdbcUtils

public final class JdbcUtils extends Object
Utility class for dealing with jdbc connections.
  • Constructor Details

    • JdbcUtils

      public JdbcUtils()
  • Method Details

    • openConnection

      public static Connection openConnection(ConnectionProvider dataSource, int connectRetries, int connectRetriesInterval, DatabaseTypeRegister databaseTypeRegister) throws MigrateDbException
      Opens a new connection from dataSource.
      Parameters:
      dataSource - The data source to obtain the connection from.
      connectRetries - The maximum number of retries when attempting to connect to the database.
      connectRetriesInterval - The maximum time between retries in seconds
      Returns:
      The new connection.
      Throws:
      MigrateDbException - if the connection could not be opened.
    • closeConnection

      public static void closeConnection(Connection connection)
      Quietly closes this connection. This method never throws an exception even if closing the connection fails.
    • closeStatement

      public static void closeStatement(Statement statement)
      Quietly closes this statement. This method never throws an exception even if closing the statement fails.
    • closeResultSet

      public static void closeResultSet(ResultSet resultSet)
      Quietly closes this resultSet. This method never throws an exception even if closing the result set fails.
    • getDatabaseMetaData

      public static DatabaseMetaData getDatabaseMetaData(Connection connection)
    • getDatabaseProductName

      public static String getDatabaseProductName(DatabaseMetaData databaseMetaData)
      Returns:
      The name of the database product. Example: Oracle, MySQL, ...
    • getDatabaseProductVersion

      public static String getDatabaseProductVersion(DatabaseMetaData databaseMetaData)
      Returns:
      The version of the database product. Example: MariaDB 10.3, ...