Package migratedb.v1.core.internal.jdbc
Class JdbcUtils
java.lang.Object
migratedb.v1.core.internal.jdbc.JdbcUtils
Utility class for dealing with jdbc connections.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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(ConnectionProvider dataSource, int connectRetries, int connectRetriesInterval, DatabaseTypeRegister databaseTypeRegister) Opens a new connection fromdataSource.
-
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 fromdataSource.- 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
Quietly closes this connection. This method never throws an exception even if closing the connection fails. -
closeStatement
Quietly closes this statement. This method never throws an exception even if closing the statement fails. -
closeResultSet
Quietly closes this resultSet. This method never throws an exception even if closing the result set fails. -
getDatabaseMetaData
-
getDatabaseProductName
- Returns:
- The name of the database product. Example: Oracle, MySQL, ...
-
getDatabaseProductVersion
- Returns:
- The version of the database product. Example: MariaDB 10.3, ...
-