001: /*
002: * Copyright 2002-2007 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: * http://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:
017: package org.springframework.jdbc.core.metadata;
018:
019: import java.sql.DatabaseMetaData;
020: import java.sql.SQLException;
021: import java.util.List;
022:
023: import org.springframework.jdbc.core.SqlParameter;
024:
025: /**
026: * Interface specifying the API to be implemented by a class providing call metadata.
027: * This is intended for internal use by Spring's
028: * {@link org.springframework.jdbc.core.simple.SimpleJdbcTemplate}.
029: *
030: * @author Thomas Risberg
031: * @since 2.5
032: */
033: public interface CallMetaDataProvider {
034:
035: /**
036: * Initialize using the provided DatabaseMetData.
037: * @param databaseMetaData used to retrieve database specific information
038: * @throws SQLException in case of initialization failure
039: */
040: void initializeWithMetaData(DatabaseMetaData databaseMetaData)
041: throws SQLException;
042:
043: /**
044: * Initialize the database specific management of procedure column meta data.
045: * This is only called for databases that are supported. This initalization
046: * can be turned off by specifying that column meta data should not be used.
047: * @param databaseMetaData used to retreive database specific information
048: * @param catalogName name of catalog to use or null
049: * @param schemaName name of schema name to use or null
050: * @param procedureName name of the stored procedure
051: * @throws SQLException in case of initialization failure
052: * @see org.springframework.jdbc.core.simple.SimpleJdbcCall#withoutProcedureColumnMetaDataAccess()
053: */
054: void initializeWithProcedureColumnMetaData(
055: DatabaseMetaData databaseMetaData, String catalogName,
056: String schemaName, String procedureName)
057: throws SQLException;
058:
059: /**
060: * Provide any modification of the procedure name passed in to match the meta data currently used.
061: * This could include alterig the case.
062: */
063: String procedureNameToUse(String procedureName);
064:
065: /**
066: * Provide any modification of the catalog name passed in to match the meta data currently used.
067: * This could include alterig the case.
068: */
069: String catalogNameToUse(String catalogName);
070:
071: /**
072: * Provide any modification of the schema name passed in to match the meta data currently used.
073: * This could include alterig the case.
074: */
075: String schemaNameToUse(String schemaName);
076:
077: /**
078: * Provide any modification of the catalog name passed in to match the meta data currently used.
079: * The reyurned value will be used for meta data lookups. This could include alterig the case used or
080: * providing a base catalog if mone provided.
081: */
082: String metaDataCatalogNameToUse(String catalogName);
083:
084: /**
085: * Provide any modification of the schema name passed in to match the meta data currently used.
086: * The reyurned value will be used for meta data lookups. This could include alterig the case used or
087: * providing a base schema if mone provided.
088: */
089: String metaDataSchemaNameToUse(String schemaName);
090:
091: /**
092: * Provide any modification of the column name passed in to match the meta data currently used.
093: * This could include alterig the case.
094: * @param parameterName name of the parameter of column
095: */
096: String parameterNameToUse(String parameterName);
097:
098: /**
099: * Create a default out parameter based on the provided meta data. This is used when no expicit
100: * parameter declaration has been made.
101: * @param parameterName the name of the parameter
102: * @param meta meta data used for this call
103: * @return the configured SqlParameter
104: */
105: SqlParameter createDefaultOutParameter(String parameterName,
106: CallParameterMetaData meta);
107:
108: /**
109: * Create a default in parameter based on the provided meta data. This is used when no expicit
110: * parameter declaration has been made.
111: * @param parameterName the name of the parameter
112: * @param meta meta data used for this call
113: * @return the configured SqlParameter
114: */
115: SqlParameter createDefaultInParameter(String parameterName,
116: CallParameterMetaData meta);
117:
118: /**
119: * Get the name of the current user. Useful for meta data lookups etc.
120: * @return current user name from database connection
121: */
122: String getUserName();
123:
124: /**
125: * Does this database support returning resultsets that should be retreived with the JDBC call
126: * {@link java.sql.Statement#getResultSet()}
127: */
128: boolean isReturnResultSetSupported();
129:
130: /**
131: * Does this database support returning resultsets as ref cursors to be retreived with
132: * {@link java.sql.CallableStatement#getObject(int)} for the specified column.
133: */
134: boolean isRefCursorSupported();
135:
136: /**
137: * Get the {@link java.sql.Types} type for columns that return resultsets as ref cursors if this feature
138: * is supported.
139: */
140: int getRefCursorSqlType();
141:
142: /**
143: * Are we using the meta data for the procedure columns?
144: */
145: boolean isProcedureColumnMetaDataUsed();
146:
147: /**
148: * Should we bypass the return parameter with the specified name.
149: * This allows the database specific implementation to skip the processing
150: * for specific results returned by the database call.
151: */
152: boolean byPassReturnParameter(String parameterName);
153:
154: /**
155: * Get the call parameter metadata that is currently used.
156: * @return List of {@link CallParameterMetaData}
157: */
158: List<CallParameterMetaData> getCallParameterMetaData();
159:
160: }
|