001/*
002 * Copyright 2002-2012 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 */
033public interface ParameterMapper {
034
035        /**
036         * Create a Map of input parameters, keyed by name.
037         * @param con JDBC connection. This is useful (and the purpose of this interface)
038         * if we need to do something RDBMS-specific with a proprietary Connection
039         * implementation class. This class conceals such proprietary details. However,
040         * it is best to avoid using such proprietary RDBMS features if possible.
041         * @throws SQLException if a SQLException is encountered setting
042         * parameter values (that is, there's no need to catch SQLException)
043         * @return Map of input parameters, keyed by name (never {@code null})
044         */
045        Map<String, ?> createMap(Connection con) throws SQLException;
046
047}