001/* 002 * Copyright 2002-2020 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.jdbc.support; 018 019import java.sql.DatabaseMetaData; 020import java.sql.SQLException; 021 022/** 023 * A callback interface used by the JdbcUtils class. Implementations of this 024 * interface perform the actual work of extracting database meta-data, but 025 * don't need to worry about exception handling. SQLExceptions will be caught 026 * and handled correctly by the JdbcUtils class. 027 * 028 * @author Thomas Risberg 029 * @author Juergen Hoeller 030 * @param <T> the result type 031 * @see JdbcUtils#extractDatabaseMetaData(javax.sql.DataSource, DatabaseMetaDataCallback) 032 */ 033@FunctionalInterface 034public interface DatabaseMetaDataCallback<T> { 035 036 /** 037 * Implementations must implement this method to process the meta-data 038 * passed in. Exactly what the implementation chooses to do is up to it. 039 * @param dbmd the DatabaseMetaData to process 040 * @return a result object extracted from the meta-data 041 * (can be an arbitrary object, as needed by the implementation) 042 * @throws SQLException if an SQLException is encountered getting 043 * column values (that is, there's no need to catch SQLException) 044 * @throws MetaDataAccessException in case of other failures while 045 * extracting meta-data (for example, reflection failure) 046 */ 047 T processMetaData(DatabaseMetaData dbmd) throws SQLException, MetaDataAccessException; 048 049}