Package migratedb.core.internal.jdbc
Enum JdbcUtils
- java.lang.Object
-
- java.lang.Enum<JdbcUtils>
-
- migratedb.core.internal.jdbc.JdbcUtils
-
- All Implemented Interfaces:
Serializable,Comparable<JdbcUtils>
public enum JdbcUtils extends Enum<JdbcUtils>
Utility class for dealing with jdbc connections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseConnection(Connection connection)Quietly closes this connection.static voidcloseResultSet(ResultSet resultSet)Quietly closes this resultSet.static voidcloseStatement(Statement statement)Quietly closes this statement.static DatabaseMetaDatagetDatabaseMetaData(Connection connection)static StringgetDatabaseProductName(DatabaseMetaData databaseMetaData)static StringgetDatabaseProductVersion(DatabaseMetaData databaseMetaData)static ConnectionopenConnection(DataSource dataSource, int connectRetries, int connectRetriesInterval, DatabaseTypeRegister databaseTypeRegister)Opens a new connection fromdataSource.static JdbcUtilsvalueOf(String name)Returns the enum constant of this type with the specified name.static JdbcUtils[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static JdbcUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JdbcUtils c : JdbcUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JdbcUtils valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
openConnection
public static Connection openConnection(DataSource dataSource, int connectRetries, int connectRetriesInterval, DatabaseTypeRegister databaseTypeRegister) throws MigrateDbException
Opens a new connection fromdataSource.- Parameters:
dataSource- The dataSource 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 connection fails.
-
closeResultSet
public static void closeResultSet(ResultSet resultSet)
Quietly closes this resultSet. This method never throws an exception even if closing the connection 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, ...
-
-