Spring Framework

org.springframework.jdbc.core.metadata
Class GenericCallMetaDataProvider

java.lang.Object
  extended by org.springframework.jdbc.core.metadata.GenericCallMetaDataProvider
All Implemented Interfaces:
CallMetaDataProvider
Direct Known Subclasses:
Db2CallMetaDataProvider, DerbyCallMetaDataProvider, OracleCallMetaDataProvider, PostgresCallMetaDataProvider, SqlServerCallMetaDataProvider, SybaseCallMetaDataProvider

public class GenericCallMetaDataProvider
extends java.lang.Object
implements CallMetaDataProvider

Generic implementation for the CallMetaDataProvider interface. This class can be extended to provide database specific behavior.

Since:
2.5
Author:
Thomas Risberg

Field Summary
protected static org.apache.commons.logging.Log logger
          Logger available to subclasses
 
Constructor Summary
protected GenericCallMetaDataProvider(java.sql.DatabaseMetaData databaseMetaData)
          Constructor used to initialize with provided database meta data.
 
Method Summary
 boolean byPassReturnParameter(java.lang.String parameterName)
          Should we bypass the return parameter with the specified name.
 java.lang.String catalogNameToUse(java.lang.String catalogName)
          Provide any modification of the catalog name passed in to match the meta data currently used.
 SqlParameter createDefaultInOutParameter(java.lang.String parameterName, CallParameterMetaData meta)
          Create a default inout parameter based on the provided meta data.
 SqlParameter createDefaultInParameter(java.lang.String parameterName, CallParameterMetaData meta)
          Create a default in parameter based on the provided meta data.
 SqlParameter createDefaultOutParameter(java.lang.String parameterName, CallParameterMetaData meta)
          Create a default out parameter based on the provided meta data.
 java.util.List<CallParameterMetaData> getCallParameterMetaData()
          Get the call parameter metadata that is currently used.
 int getRefCursorSqlType()
          Get the Types type for columns that return resultsets as ref cursors if this feature is supported.
 java.lang.String getUserName()
          Get the name of the current user.
 void initializeWithMetaData(java.sql.DatabaseMetaData databaseMetaData)
          Initialize using the provided DatabaseMetData.
 void initializeWithProcedureColumnMetaData(java.sql.DatabaseMetaData databaseMetaData, java.lang.String catalogName, java.lang.String schemaName, java.lang.String procedureName)
          Initialize the database specific management of procedure column meta data.
 boolean isProcedureColumnMetaDataUsed()
          Are we using the meta data for the procedure columns?
 boolean isRefCursorSupported()
          Does this database support returning resultsets as ref cursors to be retrieved with CallableStatement.getObject(int) for the specified column.
 boolean isReturnResultSetSupported()
          Does this database support returning resultsets that should be retrieved with the JDBC call Statement.getResultSet()
protected  boolean isStoresLowerCaseIdentifiers()
          Does the database use lower case for identifiers
protected  boolean isStoresUpperCaseIdentifiers()
          Does the database use upper case for identifiers
 boolean isSupportsCatalogsInProcedureCalls()
          Does the database support the use of catalog name in procedure calls
 boolean isSupportsSchemasInProcedureCalls()
          Does the database support the use of schema name in procedure calls
 java.lang.String metaDataCatalogNameToUse(java.lang.String catalogName)
          Provide any modification of the catalog name passed in to match the meta data currently used.
 java.lang.String metaDataSchemaNameToUse(java.lang.String schemaName)
          Provide any modification of the schema name passed in to match the meta data currently used.
 java.lang.String parameterNameToUse(java.lang.String parameterName)
          Provide any modification of the column name passed in to match the meta data currently used.
 java.lang.String procedureNameToUse(java.lang.String procedureName)
          Provide any modification of the procedure name passed in to match the meta data currently used.
 java.lang.String schemaNameToUse(java.lang.String schemaName)
          Provide any modification of the schema name passed in to match the meta data currently used.
protected  void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
          Specify whether the database uses lower case for identifiers
protected  void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
          Specify whether the database uses upper case for identifiers
protected  void setSupportsCatalogsInProcedureCalls(boolean supportsCatalogsInProcedureCalls)
          Specify whether the database supports the use of catalog name in procedure calls
protected  void setSupportsSchemasInProcedureCalls(boolean supportsSchemasInProcedureCalls)
          Specify whether the database supports the use of schema name in procedure calls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

GenericCallMetaDataProvider

protected GenericCallMetaDataProvider(java.sql.DatabaseMetaData databaseMetaData)
                               throws java.sql.SQLException
Constructor used to initialize with provided database meta data.

Parameters:
databaseMetaData - meta data to be used
Throws:
java.sql.SQLException
Method Detail

initializeWithMetaData

public void initializeWithMetaData(java.sql.DatabaseMetaData databaseMetaData)
                            throws java.sql.SQLException
Description copied from interface: CallMetaDataProvider
Initialize using the provided DatabaseMetData.

Specified by:
initializeWithMetaData in interface CallMetaDataProvider
Parameters:
databaseMetaData - used to retrieve database specific information
Throws:
java.sql.SQLException - in case of initialization failure

initializeWithProcedureColumnMetaData

public void initializeWithProcedureColumnMetaData(java.sql.DatabaseMetaData databaseMetaData,
                                                  java.lang.String catalogName,
                                                  java.lang.String schemaName,
                                                  java.lang.String procedureName)
                                           throws java.sql.SQLException
Description copied from interface: CallMetaDataProvider
Initialize the database specific management of procedure column meta data. This is only called for databases that are supported. This initalization can be turned off by specifying that column meta data should not be used.

Specified by:
initializeWithProcedureColumnMetaData in interface CallMetaDataProvider
Parameters:
databaseMetaData - used to retrieve database specific information
catalogName - name of catalog to use or null
schemaName - name of schema name to use or null
procedureName - name of the stored procedure
Throws:
java.sql.SQLException - in case of initialization failure
See Also:
SimpleJdbcCall.withoutProcedureColumnMetaDataAccess()

getCallParameterMetaData

public java.util.List<CallParameterMetaData> getCallParameterMetaData()
Description copied from interface: CallMetaDataProvider
Get the call parameter metadata that is currently used.

Specified by:
getCallParameterMetaData in interface CallMetaDataProvider
Returns:
List of CallParameterMetaData

procedureNameToUse

public java.lang.String procedureNameToUse(java.lang.String procedureName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the procedure name passed in to match the meta data currently used. This could include alterig the case.

Specified by:
procedureNameToUse in interface CallMetaDataProvider

catalogNameToUse

public java.lang.String catalogNameToUse(java.lang.String catalogName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the catalog name passed in to match the meta data currently used. This could include alterig the case.

Specified by:
catalogNameToUse in interface CallMetaDataProvider

schemaNameToUse

public java.lang.String schemaNameToUse(java.lang.String schemaName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the schema name passed in to match the meta data currently used. This could include alterig the case.

Specified by:
schemaNameToUse in interface CallMetaDataProvider

metaDataCatalogNameToUse

public java.lang.String metaDataCatalogNameToUse(java.lang.String catalogName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the catalog name passed in to match the meta data currently used. The reyurned value will be used for meta data lookups. This could include alterig the case used or providing a base catalog if mone provided.

Specified by:
metaDataCatalogNameToUse in interface CallMetaDataProvider

metaDataSchemaNameToUse

public java.lang.String metaDataSchemaNameToUse(java.lang.String schemaName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the schema name passed in to match the meta data currently used. The reyurned value will be used for meta data lookups. This could include alterig the case used or providing a base schema if mone provided.

Specified by:
metaDataSchemaNameToUse in interface CallMetaDataProvider

parameterNameToUse

public java.lang.String parameterNameToUse(java.lang.String parameterName)
Description copied from interface: CallMetaDataProvider
Provide any modification of the column name passed in to match the meta data currently used. This could include altering the case.

Specified by:
parameterNameToUse in interface CallMetaDataProvider
Parameters:
parameterName - name of the parameter of column

byPassReturnParameter

public boolean byPassReturnParameter(java.lang.String parameterName)
Description copied from interface: CallMetaDataProvider
Should we bypass the return parameter with the specified name. This allows the database specific implementation to skip the processing for specific results returned by the database call.

Specified by:
byPassReturnParameter in interface CallMetaDataProvider

createDefaultOutParameter

public SqlParameter createDefaultOutParameter(java.lang.String parameterName,
                                              CallParameterMetaData meta)
Description copied from interface: CallMetaDataProvider
Create a default out parameter based on the provided meta data. This is used when no explicit parameter declaration has been made.

Specified by:
createDefaultOutParameter in interface CallMetaDataProvider
Parameters:
parameterName - the name of the parameter
meta - meta data used for this call
Returns:
the configured SqlOutParameter

createDefaultInOutParameter

public SqlParameter createDefaultInOutParameter(java.lang.String parameterName,
                                                CallParameterMetaData meta)
Description copied from interface: CallMetaDataProvider
Create a default inout parameter based on the provided meta data. This is used when no explicit parameter declaration has been made.

Specified by:
createDefaultInOutParameter in interface CallMetaDataProvider
Parameters:
parameterName - the name of the parameter
meta - meta data used for this call
Returns:
the configured SqlInOutParameter

createDefaultInParameter

public SqlParameter createDefaultInParameter(java.lang.String parameterName,
                                             CallParameterMetaData meta)
Description copied from interface: CallMetaDataProvider
Create a default in parameter based on the provided meta data. This is used when no explicit parameter declaration has been made.

Specified by:
createDefaultInParameter in interface CallMetaDataProvider
Parameters:
parameterName - the name of the parameter
meta - meta data used for this call
Returns:
the configured SqlParameter

getUserName

public java.lang.String getUserName()
Description copied from interface: CallMetaDataProvider
Get the name of the current user. Useful for meta data lookups etc.

Specified by:
getUserName in interface CallMetaDataProvider
Returns:
current user name from database connection

isReturnResultSetSupported

public boolean isReturnResultSetSupported()
Description copied from interface: CallMetaDataProvider
Does this database support returning resultsets that should be retrieved with the JDBC call Statement.getResultSet()

Specified by:
isReturnResultSetSupported in interface CallMetaDataProvider

isRefCursorSupported

public boolean isRefCursorSupported()
Description copied from interface: CallMetaDataProvider
Does this database support returning resultsets as ref cursors to be retrieved with CallableStatement.getObject(int) for the specified column.

Specified by:
isRefCursorSupported in interface CallMetaDataProvider

getRefCursorSqlType

public int getRefCursorSqlType()
Description copied from interface: CallMetaDataProvider
Get the Types type for columns that return resultsets as ref cursors if this feature is supported.

Specified by:
getRefCursorSqlType in interface CallMetaDataProvider

isProcedureColumnMetaDataUsed

public boolean isProcedureColumnMetaDataUsed()
Description copied from interface: CallMetaDataProvider
Are we using the meta data for the procedure columns?

Specified by:
isProcedureColumnMetaDataUsed in interface CallMetaDataProvider

setSupportsCatalogsInProcedureCalls

protected void setSupportsCatalogsInProcedureCalls(boolean supportsCatalogsInProcedureCalls)
Specify whether the database supports the use of catalog name in procedure calls


isSupportsCatalogsInProcedureCalls

public boolean isSupportsCatalogsInProcedureCalls()
Does the database support the use of catalog name in procedure calls

Specified by:
isSupportsCatalogsInProcedureCalls in interface CallMetaDataProvider

setSupportsSchemasInProcedureCalls

protected void setSupportsSchemasInProcedureCalls(boolean supportsSchemasInProcedureCalls)
Specify whether the database supports the use of schema name in procedure calls


isSupportsSchemasInProcedureCalls

public boolean isSupportsSchemasInProcedureCalls()
Does the database support the use of schema name in procedure calls

Specified by:
isSupportsSchemasInProcedureCalls in interface CallMetaDataProvider

setStoresUpperCaseIdentifiers

protected void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
Specify whether the database uses upper case for identifiers


isStoresUpperCaseIdentifiers

protected boolean isStoresUpperCaseIdentifiers()
Does the database use upper case for identifiers


setStoresLowerCaseIdentifiers

protected void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
Specify whether the database uses lower case for identifiers


isStoresLowerCaseIdentifiers

protected boolean isStoresLowerCaseIdentifiers()
Does the database use lower case for identifiers


Spring Framework