001/* 002 * Copyright 2002-2018 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.core; 018 019import java.sql.Connection; 020import java.sql.SQLException; 021import java.util.Map; 022 023/** 024 * Implement this interface when parameters need to be customized based 025 * on the connection. We might need to do this to make use of proprietary 026 * features, available only with a specific Connection type. 027 * 028 * @author Rod Johnson 029 * @author Thomas Risberg 030 * @see CallableStatementCreatorFactory#newCallableStatementCreator(ParameterMapper) 031 * @see org.springframework.jdbc.object.StoredProcedure#execute(ParameterMapper) 032 */ 033@FunctionalInterface 034public interface ParameterMapper { 035 036 /** 037 * Create a Map of input parameters, keyed by name. 038 * @param con a JDBC connection. This is useful (and the purpose of this interface) 039 * if we need to do something RDBMS-specific with a proprietary Connection 040 * implementation class. This class conceals such proprietary details. However, 041 * it is best to avoid using such proprietary RDBMS features if possible. 042 * @return a Map of input parameters, keyed by name (never {@code null}) 043 * @throws SQLException if an SQLException is encountered setting 044 * parameter values (that is, there's no need to catch SQLException) 045 */ 046 Map<String, ?> createMap(Connection con) throws SQLException; 047 048}