parent
9bfbe36b1c
commit
c38bde259a
|
@ -120,8 +120,7 @@ public abstract class StatementCreatorUtils {
|
||||||
* @param inValue the value to set
|
* @param inValue the value to set
|
||||||
* @throws SQLException if thrown by PreparedStatement methods
|
* @throws SQLException if thrown by PreparedStatement methods
|
||||||
*/
|
*/
|
||||||
public static void setParameterValue(
|
public static void setParameterValue(PreparedStatement ps, int paramIndex, SqlParameter param, Object inValue)
|
||||||
PreparedStatement ps, int paramIndex, SqlParameter param, Object inValue)
|
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
setParameterValueInternal(ps, paramIndex, param.getSqlType(), param.getTypeName(), param.getScale(), inValue);
|
setParameterValueInternal(ps, paramIndex, param.getSqlType(), param.getTypeName(), param.getScale(), inValue);
|
||||||
|
@ -137,8 +136,7 @@ public abstract class StatementCreatorUtils {
|
||||||
* @throws SQLException if thrown by PreparedStatement methods
|
* @throws SQLException if thrown by PreparedStatement methods
|
||||||
* @see SqlTypeValue
|
* @see SqlTypeValue
|
||||||
*/
|
*/
|
||||||
public static void setParameterValue(
|
public static void setParameterValue(PreparedStatement ps, int paramIndex, int sqlType, Object inValue)
|
||||||
PreparedStatement ps, int paramIndex, int sqlType, Object inValue)
|
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
setParameterValueInternal(ps, paramIndex, sqlType, null, null, inValue);
|
setParameterValueInternal(ps, paramIndex, sqlType, null, null, inValue);
|
||||||
|
@ -156,9 +154,8 @@ public abstract class StatementCreatorUtils {
|
||||||
* @throws SQLException if thrown by PreparedStatement methods
|
* @throws SQLException if thrown by PreparedStatement methods
|
||||||
* @see SqlTypeValue
|
* @see SqlTypeValue
|
||||||
*/
|
*/
|
||||||
public static void setParameterValue(
|
public static void setParameterValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName,
|
||||||
PreparedStatement ps, int paramIndex, int sqlType, String typeName, Object inValue)
|
Object inValue) throws SQLException {
|
||||||
throws SQLException {
|
|
||||||
|
|
||||||
setParameterValueInternal(ps, paramIndex, sqlType, typeName, null, inValue);
|
setParameterValueInternal(ps, paramIndex, sqlType, typeName, null, inValue);
|
||||||
}
|
}
|
||||||
|
@ -177,9 +174,8 @@ public abstract class StatementCreatorUtils {
|
||||||
* @throws SQLException if thrown by PreparedStatement methods
|
* @throws SQLException if thrown by PreparedStatement methods
|
||||||
* @see SqlTypeValue
|
* @see SqlTypeValue
|
||||||
*/
|
*/
|
||||||
private static void setParameterValueInternal(
|
private static void setParameterValueInternal(PreparedStatement ps, int paramIndex, int sqlType,
|
||||||
PreparedStatement ps, int paramIndex, int sqlType, String typeName, Integer scale, Object inValue)
|
String typeName, Integer scale, Object inValue) throws SQLException {
|
||||||
throws SQLException {
|
|
||||||
|
|
||||||
String typeNameToUse = typeName;
|
String typeNameToUse = typeName;
|
||||||
int sqlTypeToUse = sqlType;
|
int sqlTypeToUse = sqlType;
|
||||||
|
@ -190,8 +186,7 @@ public abstract class StatementCreatorUtils {
|
||||||
SqlParameterValue parameterValue = (SqlParameterValue) inValue;
|
SqlParameterValue parameterValue = (SqlParameterValue) inValue;
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Overriding type info with runtime info from SqlParameterValue: column index " + paramIndex +
|
logger.debug("Overriding type info with runtime info from SqlParameterValue: column index " + paramIndex +
|
||||||
", SQL type " + parameterValue.getSqlType() +
|
", SQL type " + parameterValue.getSqlType() + ", type name " + parameterValue.getTypeName());
|
||||||
", Type name " + parameterValue.getTypeName());
|
|
||||||
}
|
}
|
||||||
if (parameterValue.getSqlType() != SqlTypeValue.TYPE_UNKNOWN) {
|
if (parameterValue.getSqlType() != SqlTypeValue.TYPE_UNKNOWN) {
|
||||||
sqlTypeToUse = parameterValue.getSqlType();
|
sqlTypeToUse = parameterValue.getSqlType();
|
||||||
|
@ -221,9 +216,7 @@ public abstract class StatementCreatorUtils {
|
||||||
* Set the specified PreparedStatement parameter to null,
|
* Set the specified PreparedStatement parameter to null,
|
||||||
* respecting database-specific peculiarities.
|
* respecting database-specific peculiarities.
|
||||||
*/
|
*/
|
||||||
private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, String typeName)
|
private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException {
|
||||||
throws SQLException {
|
|
||||||
|
|
||||||
if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
|
if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
|
||||||
boolean useSetObject = false;
|
boolean useSetObject = false;
|
||||||
sqlType = Types.NULL;
|
sqlType = Types.NULL;
|
||||||
|
@ -232,10 +225,9 @@ public abstract class StatementCreatorUtils {
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("JDBC 3.0 getParameterType call not supported: " + ex);
|
logger.debug("JDBC 3.0 getParameterType call not supported - using fallback method instead: " + ex);
|
||||||
}
|
}
|
||||||
// JDBC driver not compliant with JDBC 3.0
|
// JDBC driver not compliant with JDBC 3.0 -> proceed with database-specific checks
|
||||||
// -> proceed with database-specific checks
|
|
||||||
try {
|
try {
|
||||||
DatabaseMetaData dbmd = ps.getConnection().getMetaData();
|
DatabaseMetaData dbmd = ps.getConnection().getMetaData();
|
||||||
String databaseProductName = dbmd.getDatabaseProductName();
|
String databaseProductName = dbmd.getDatabaseProductName();
|
||||||
|
|
Loading…
Reference in New Issue