public abstract class StatementCreatorUtils
extends java.lang.Object
Used by PreparedStatementCreatorFactory and CallableStatementCreatorFactory, but also available for direct use in custom setter/creator implementations.
PreparedStatementSetter
,
PreparedStatementCreator
,
CallableStatementCreator
,
PreparedStatementCreatorFactory
,
CallableStatementCreatorFactory
,
SqlParameter
,
SqlTypeValue
,
SqlLobValue
Modifier and Type | Field and Description |
---|---|
(package private) static java.util.Set<java.lang.String> |
driversWithNoSupportForGetParameterType |
private static java.util.Map<java.lang.Class<?>,java.lang.Integer> |
javaTypeToSqlTypeMap |
private static Log |
logger |
Constructor and Description |
---|
StatementCreatorUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanupParameters(java.util.Collection<?> paramValues)
Clean up all resources held by parameter values which were passed to an
execute method.
|
static void |
cleanupParameters(java.lang.Object... paramValues)
Clean up all resources held by parameter values which were passed to an
execute method.
|
private static boolean |
isDateValue(java.lang.Class<?> inValueType)
Check whether the given value is a
java.util.Date
(but not one of the JDBC-specific subclasses). |
private static boolean |
isStringValue(java.lang.Class<?> inValueType)
Check whether the given value can be treated as a String value.
|
static int |
javaTypeToSqlParameterType(java.lang.Class<?> javaType)
Derive a default SQL type from the given Java type.
|
private static void |
setNull(java.sql.PreparedStatement ps,
int paramIndex,
int sqlType,
java.lang.String typeName)
Set the specified PreparedStatement parameter to null,
respecting database-specific peculiarities.
|
static void |
setParameterValue(java.sql.PreparedStatement ps,
int paramIndex,
int sqlType,
java.lang.Object inValue)
Set the value for a parameter.
|
static void |
setParameterValue(java.sql.PreparedStatement ps,
int paramIndex,
int sqlType,
java.lang.String typeName,
java.lang.Object inValue)
Set the value for a parameter.
|
static void |
setParameterValue(java.sql.PreparedStatement ps,
int paramIndex,
SqlParameter param,
java.lang.Object inValue)
Set the value for a parameter.
|
private static void |
setParameterValueInternal(java.sql.PreparedStatement ps,
int paramIndex,
int sqlType,
java.lang.String typeName,
java.lang.Integer scale,
java.lang.Object inValue)
Set the value for a parameter.
|
private static void |
setValue(java.sql.PreparedStatement ps,
int paramIndex,
int sqlType,
java.lang.String typeName,
java.lang.Integer scale,
java.lang.Object inValue) |
private static final Log logger
static final java.util.Set<java.lang.String> driversWithNoSupportForGetParameterType
private static final java.util.Map<java.lang.Class<?>,java.lang.Integer> javaTypeToSqlTypeMap
public static int javaTypeToSqlParameterType(java.lang.Class<?> javaType)
javaType
- the Java type to translatenull
if none foundpublic static void setParameterValue(java.sql.PreparedStatement ps, int paramIndex, SqlParameter param, java.lang.Object inValue) throws java.sql.SQLException
ps
- the prepared statement or callable statementparamIndex
- index of the parameter we are settingparam
- the parameter as it is declared including typeinValue
- the value to setjava.sql.SQLException
- if thrown by PreparedStatement methodspublic static void setParameterValue(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.Object inValue) throws java.sql.SQLException
ps
- the prepared statement or callable statementparamIndex
- index of the parameter we are settingsqlType
- the SQL type of the parameterinValue
- the value to set (plain value or a SqlTypeValue)java.sql.SQLException
- if thrown by PreparedStatement methodsSqlTypeValue
public static void setParameterValue(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.String typeName, java.lang.Object inValue) throws java.sql.SQLException
ps
- the prepared statement or callable statementparamIndex
- index of the parameter we are settingsqlType
- the SQL type of the parametertypeName
- the type name of the parameter
(optional, only used for SQL NULL and SqlTypeValue)inValue
- the value to set (plain value or a SqlTypeValue)java.sql.SQLException
- if thrown by PreparedStatement methodsSqlTypeValue
private static void setParameterValueInternal(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.String typeName, java.lang.Integer scale, java.lang.Object inValue) throws java.sql.SQLException
ps
- the prepared statement or callable statementparamIndex
- index of the parameter we are settingsqlType
- the SQL type of the parametertypeName
- the type name of the parameter
(optional, only used for SQL NULL and SqlTypeValue)scale
- the number of digits after the decimal point
(for DECIMAL and NUMERIC types)inValue
- the value to set (plain value or a SqlTypeValue)java.sql.SQLException
- if thrown by PreparedStatement methodsSqlTypeValue
private static void setNull(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.String typeName) throws java.sql.SQLException
java.sql.SQLException
private static void setValue(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.String typeName, java.lang.Integer scale, java.lang.Object inValue) throws java.sql.SQLException
java.sql.SQLException
private static boolean isStringValue(java.lang.Class<?> inValueType)
private static boolean isDateValue(java.lang.Class<?> inValueType)
java.util.Date
(but not one of the JDBC-specific subclasses).public static void cleanupParameters(java.lang.Object... paramValues)
paramValues
- parameter values supplied. May be null
.DisposableSqlTypeValue.cleanup()
,
SqlLobValue.cleanup()
public static void cleanupParameters(java.util.Collection<?> paramValues)
paramValues
- parameter values supplied. May be null
.DisposableSqlTypeValue.cleanup()
,
SqlLobValue.cleanup()