spring-framework / org.springframework.jdbc.support / JdbcUtils / extractDatabaseMetaData

extractDatabaseMetaData

open static fun extractDatabaseMetaData(dataSource: DataSource, action: DatabaseMetaDataCallback): Any

Extract database meta data via the given DatabaseMetaDataCallback.

This method will open a connection to the database and retrieve the database metadata. Since this method is called before the exception translation feature is configured for a datasource, this method can not rely on the SQLException translation functionality.

Any exceptions will be wrapped in a MetaDataAccessException. This is a checked exception and any calling code should catch and handle this exception. You can just log the error and hope for the best, but there is probably a more serious error that will reappear when you try to access the database again.

Parameters

dataSource - the DataSource to extract metadata for

action - callback that will do the actual work

Exceptions

MetaDataAccessException - if meta data access failed

Return
object containing the extracted information, as returned by the DatabaseMetaDataCallback's processMetaData method

open static fun <T : Any> extractDatabaseMetaData(dataSource: DataSource, metaDataMethodName: String): T

Call the specified method on DatabaseMetaData for the given DataSource, and extract the invocation result.

Parameters

dataSource - the DataSource to extract meta data for

metaDataMethodName - the name of the DatabaseMetaData method to call

Exceptions

MetaDataAccessException - if we couldn't access the DatabaseMetaData or failed to invoke the specified method

Return
the object returned by the specified DatabaseMetaData method

See Also
java.sql.DatabaseMetaData