* @param context the class that holds configuration and metedata
* @return instance of the CallMetaDataProvider implementation to be used
*/
static public CallMetaDataProvider createMetaDataProvider(final DataSource dataSource, final CallMetaDataContext context) {
try {
CallMetaDataProvider provider = (CallMetaDataProvider) JdbcUtils.extractDatabaseMetaData(dataSource, new DatabaseMetaDataCallback() {
public Object processMetaData(DatabaseMetaData databaseMetaData) throws SQLException, MetaDataAccessException {
String databaseProductName = JdbcUtils.commonDatabaseName(databaseMetaData.getDatabaseProductName());
boolean accessProcedureColumnMetaData = context.isAccessCallParameterMetaData();
if (context.isFunction()) {
if (!supportedDatabaseProductsForFunctions.contains(databaseProductName)) {
if (accessProcedureColumnMetaData) {
accessProcedureColumnMetaData = false;
}
}
}
else {
if (!supportedDatabaseProductsForProcedures.contains(databaseProductName)) {
if (accessProcedureColumnMetaData) {
accessProcedureColumnMetaData = false;
}
}
}
CallMetaDataProvider provider = null;
if ("Oracle".equals(databaseProductName)) { //$NON-NLS-1$
provider = new OracleTypeHandler(databaseMetaData);
}
if (provider != null){
provider.initializeWithMetaData(databaseMetaData);
if (accessProcedureColumnMetaData) {
provider.initializeWithProcedureColumnMetaData(
databaseMetaData, context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
}
}
return provider;