List of usage examples for java.sql Types TIME
int TIME
To view the source code for java.sql Types TIME.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIME
.
From source file:org.jumpmind.db.model.Column.java
/** * Tries to parse the default value of the column and returns it as an * object of the corresponding java type. If the value could not be parsed, * then the original definition is returned. * //from w w w. ja va 2 s . c o m * @return The parsed default value */ public Object getParsedDefaultValue() { if ((defaultValue != null) && (defaultValue.length() > 0)) { try { switch (mappedTypeCode) { case Types.TINYINT: case Types.SMALLINT: return new Short(defaultValue); case Types.INTEGER: try { return new Integer(defaultValue); } catch (NumberFormatException e) { return new Long(defaultValue); } case Types.BIGINT: return new Long(defaultValue); case Types.DECIMAL: case Types.NUMERIC: return new BigDecimal(defaultValue); case Types.REAL: return new Float(defaultValue); case Types.DOUBLE: case Types.FLOAT: return new Double(defaultValue); case Types.DATE: return Date.valueOf(defaultValue); case Types.TIME: return Time.valueOf(defaultValue); case Types.TIMESTAMP: return Timestamp.valueOf(defaultValue); case Types.BIT: return FormatUtils.toBoolean(defaultValue); default: if (PlatformUtils.supportsJava14JdbcTypes() && (mappedTypeCode == PlatformUtils.determineBooleanTypeCode())) { return FormatUtils.toBoolean(defaultValue); } break; } } catch (NumberFormatException ex) { return null; } catch (IllegalArgumentException ex) { return null; } } return defaultValue; }
From source file:com.streamsets.pipeline.lib.jdbc.JdbcUtil.java
public Map<String, String> getMinimumOffsetValues(Connection connection, String schema, String tableName, QuoteChar quoteChar, Collection<String> offsetColumnNames) throws SQLException { Map<String, String> minOffsetValues = new HashMap<>(); final String qualifiedName = TableContextUtil.getQuotedQualifiedTableName(schema, tableName, quoteChar.getQuoteCharacter()); for (String offsetColumn : offsetColumnNames) { final String minOffsetQuery = String.format(MIN_OFFSET_VALUE_QUERY, offsetColumn, qualifiedName); try (Statement st = connection.createStatement(); ResultSet rs = st.executeQuery(minOffsetQuery)) { if (rs.next()) { String minValue = null; final int colType = rs.getMetaData().getColumnType(MIN_OFFSET_VALUE_QUERY_RESULT_SET_INDEX); switch (colType) { case Types.DATE: java.sql.Date date = rs.getDate(MIN_OFFSET_VALUE_QUERY_RESULT_SET_INDEX); if (date != null) { minValue = String.valueOf(date.toInstant().toEpochMilli()); }//from ww w . j a v a2s . c o m break; case Types.TIME: java.sql.Time time = rs.getTime(MIN_OFFSET_VALUE_QUERY_RESULT_SET_INDEX); if (time != null) { minValue = String.valueOf(time.toInstant().toEpochMilli()); } break; case Types.TIMESTAMP: Timestamp timestamp = rs.getTimestamp(MIN_OFFSET_VALUE_QUERY_RESULT_SET_INDEX); if (timestamp != null) { final Instant instant = timestamp.toInstant(); minValue = String.valueOf(instant.toEpochMilli()); } break; default: minValue = rs.getString(MIN_OFFSET_VALUE_QUERY_RESULT_SET_INDEX); break; } if (minValue != null) { minOffsetValues.put(offsetColumn, minValue); } } else { LOG.warn("Unable to get minimum offset value using query {}; result set had no rows", minOffsetQuery); } } } return minOffsetValues; }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java
/** * Determines if there are invalid values specified in the initial offset value * for columns./*w ww . j a v a 2s. co m*/ */ //@VisibleForTesting void checkForInvalidInitialOffsetValues(PushSource.Context context, List<Stage.ConfigIssue> issues, String qualifiedTableName, LinkedHashMap<String, Integer> offsetColumnToType, Map<String, String> offsetColumnToStartOffset) throws StageException { List<String> invalidInitialOffsetFieldAndValue = new ArrayList<>(); offsetColumnToType.forEach((offsetColumn, offsetSqlType) -> { String initialOffsetValue = offsetColumnToStartOffset.get(offsetColumn); try { if (jdbcUtil.isSqlTypeOneOf(offsetSqlType, Types.DATE, Types.TIME, Types.TIMESTAMP)) { Long.valueOf(initialOffsetValue); //NOSONAR } else { //Use native field conversion strategy to conver string to specify type and get value Field.create(OffsetQueryUtil.SQL_TYPE_TO_FIELD_TYPE.get(offsetSqlType), initialOffsetValue) .getValue(); } } catch (IllegalArgumentException e) { LOG.error(Utils.format("Invalid Initial Offset Value {} for column {} in table {}", initialOffsetValue, offsetColumn, qualifiedTableName), e); invalidInitialOffsetFieldAndValue.add(offsetColumn + " - " + initialOffsetValue); } }); if (!invalidInitialOffsetFieldAndValue.isEmpty()) { throw new StageException(JdbcErrors.JDBC_72, qualifiedTableName, COMMA_JOINER.join(invalidInitialOffsetFieldAndValue)); } }
From source file:org.apache.synapse.mediators.db.AbstractDBMediator.java
/** * Return a Prepared statement for the given Statement object, which is ready to be executed * * @param stmnt SQL stataement to be executed * @param con The connection to be used * @param msgCtx Current message context * @return a PreparedStatement//from www.j a v a 2 s .c o m * @throws SQLException on error */ protected PreparedStatement getPreparedStatement(Statement stmnt, Connection con, MessageContext msgCtx) throws SQLException { SynapseLog synLog = getLog(msgCtx); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("Getting a connection from DataSource " + getDSName() + " and preparing statement : " + stmnt.getRawStatement()); } if (con == null) { String msg = "Connection from DataSource " + getDSName() + " is null."; log.error(msg); throw new SynapseException(msg); } if (dataSource instanceof BasicDataSource) { BasicDataSource basicDataSource = (BasicDataSource) dataSource; int numActive = basicDataSource.getNumActive(); int numIdle = basicDataSource.getNumIdle(); String connectionId = Integer.toHexString(con.hashCode()); DBPoolView dbPoolView = getDbPoolView(); if (dbPoolView != null) { dbPoolView.setNumActive(numActive); dbPoolView.setNumIdle(numIdle); dbPoolView.updateConnectionUsage(connectionId); } if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("[ DB Connection : " + con + " ]"); synLog.traceOrDebug("[ DB Connection instance identifier : " + connectionId + " ]"); synLog.traceOrDebug("[ Number of Active Connection : " + numActive + " ]"); synLog.traceOrDebug("[ Number of Idle Connection : " + numIdle + " ]"); } } PreparedStatement ps = con.prepareStatement(stmnt.getRawStatement()); // set parameters if any List<Statement.Parameter> params = stmnt.getParameters(); int column = 1; for (Statement.Parameter param : params) { if (param == null) { continue; } String value = (param.getPropertyName() != null ? param.getPropertyName() : param.getXpath().stringValueOf(msgCtx)); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("Setting as parameter : " + column + " value : " + value + " as JDBC Type : " + param.getType() + "(see java.sql.Types for valid " + "types)"); } switch (param.getType()) { // according to J2SE 1.5 /docs/guide/jdbc/getstart/mapping.html case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: { if (value != null && value.length() != 0) { ps.setString(column++, value); } else { ps.setString(column++, null); } break; } case Types.NUMERIC: case Types.DECIMAL: { if (value != null && value.length() != 0) { ps.setBigDecimal(column++, new BigDecimal(value)); } else { ps.setBigDecimal(column++, null); } break; } case Types.BIT: { if (value != null && value.length() != 0) { ps.setBoolean(column++, Boolean.parseBoolean(value)); } else { ps.setNull(column++, Types.BIT); } break; } case Types.TINYINT: { if (value != null && value.length() != 0) { ps.setByte(column++, Byte.parseByte(value)); } else { ps.setNull(column++, Types.TINYINT); } break; } case Types.SMALLINT: { if (value != null && value.length() != 0) { ps.setShort(column++, Short.parseShort(value)); } else { ps.setNull(column++, Types.SMALLINT); } break; } case Types.INTEGER: { if (value != null && value.length() != 0) { ps.setInt(column++, Integer.parseInt(value)); } else { ps.setNull(column++, Types.INTEGER); } break; } case Types.BIGINT: { if (value != null && value.length() != 0) { ps.setLong(column++, Long.parseLong(value)); } else { ps.setNull(column++, Types.BIGINT); } break; } case Types.REAL: { if (value != null && value.length() != 0) { ps.setFloat(column++, Float.parseFloat(value)); } else { ps.setNull(column++, Types.REAL); } break; } case Types.FLOAT: { if (value != null && value.length() != 0) { ps.setDouble(column++, Double.parseDouble(value)); } else { ps.setNull(column++, Types.FLOAT); } break; } case Types.DOUBLE: { if (value != null && value.length() != 0) { ps.setDouble(column++, Double.parseDouble(value)); } else { ps.setNull(column++, Types.DOUBLE); } break; } // skip BINARY, VARBINARY and LONGVARBINARY case Types.DATE: { if (value != null && value.length() != 0) { ps.setDate(column++, Date.valueOf(value)); } else { ps.setNull(column++, Types.DATE); } break; } case Types.TIME: { if (value != null && value.length() != 0) { ps.setTime(column++, Time.valueOf(value)); } else { ps.setNull(column++, Types.TIME); } break; } case Types.TIMESTAMP: { if (value != null && value.length() != 0) { ps.setTimestamp(column++, Timestamp.valueOf(value)); } else { ps.setNull(column++, Types.TIMESTAMP); } break; } // skip CLOB, BLOB, ARRAY, DISTINCT, STRUCT, REF, JAVA_OBJECT default: { String msg = "Trying to set an un-supported JDBC Type : " + param.getType() + " against column : " + column + " and statement : " + stmnt.getRawStatement() + " used by a DB mediator against DataSource : " + getDSName() + " (see java.sql.Types for valid type values)"; handleException(msg, msgCtx); } } } if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("Successfully prepared statement : " + stmnt.getRawStatement() + " against DataSource : " + getDSName()); } return ps; }
From source file:org.netflux.core.FieldMetadata.java
/** * Returns a string representation of the provided type. * //from www. j a va2 s . c om * @param type the type from {@link Types} to transform to a string. * @return a string representation of the provided type. */ public static String typeToString(int type) { switch (type) { case Types.ARRAY: return "ARRAY"; case Types.BIGINT: return "BIGINT"; case Types.BINARY: return "BINARY"; case Types.BIT: return "BIT"; case Types.BLOB: return "BLOB"; case Types.BOOLEAN: return "BOOLEAN"; case Types.CHAR: return "CHAR"; case Types.CLOB: return "CLOB"; case Types.DATALINK: return "DATALINK"; case Types.DATE: return "DATE"; case Types.DECIMAL: return "DECIMAL"; case Types.DISTINCT: return "DISTINCT"; case Types.DOUBLE: return "DOUBLE"; case Types.FLOAT: return "FLOAT"; case Types.INTEGER: return "INTEGER"; case Types.JAVA_OBJECT: return "JAVA_OBJECT"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.LONGVARCHAR: return "LONGVARCHAR"; case Types.NULL: return "NULL"; case Types.NUMERIC: return "NUMERIC"; case Types.OTHER: return "OTHER"; case Types.REAL: return "REAL"; case Types.REF: return "REF"; case Types.SMALLINT: return "SMALLINT"; case Types.STRUCT: return "STRUCT"; case Types.TIME: return "TIME"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.TINYINT: return "TINYINT"; case Types.VARBINARY: return "VARBINARY"; case Types.VARCHAR: return "VARCHAR"; default: return "*unsupported type*"; } }
From source file:nl.nn.adapterframework.jdbc.JdbcFacade.java
protected void applyParameters(PreparedStatement statement, ParameterValueList parameters) throws SQLException, SenderException { // statement.clearParameters(); /*//from ww w . java 2 s. com // getParameterMetaData() is not supported on the WebSphere java.sql.PreparedStatement implementation. int senderParameterCount = parameters.size(); int statementParameterCount = statement.getParameterMetaData().getParameterCount(); if (statementParameterCount<senderParameterCount) { throw new SenderException(getLogPrefix()+"statement has more ["+statementParameterCount+"] parameters defined than sender ["+senderParameterCount+"]"); } */ for (int i = 0; i < parameters.size(); i++) { ParameterValue pv = parameters.getParameterValue(i); String paramType = pv.getDefinition().getType(); Object value = pv.getValue(); // log.debug("applying parameter ["+(i+1)+","+parameters.getParameterValue(i).getDefinition().getName()+"], value["+parameterValue+"]"); if (Parameter.TYPE_DATE.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.DATE); } else { statement.setDate(i + 1, new java.sql.Date(((Date) value).getTime())); } } else if (Parameter.TYPE_DATETIME.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.TIMESTAMP); } else { statement.setTimestamp(i + 1, new Timestamp(((Date) value).getTime())); } } else if (Parameter.TYPE_TIMESTAMP.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.TIMESTAMP); } else { statement.setTimestamp(i + 1, new Timestamp(((Date) value).getTime())); } } else if (Parameter.TYPE_TIME.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.TIME); } else { statement.setTime(i + 1, new java.sql.Time(((Date) value).getTime())); } } else if (Parameter.TYPE_XMLDATETIME.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.TIMESTAMP); } else { statement.setTimestamp(i + 1, new Timestamp(((Date) value).getTime())); } } else if (Parameter.TYPE_NUMBER.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.NUMERIC); } else { statement.setDouble(i + 1, ((Number) value).doubleValue()); } } else if (Parameter.TYPE_INTEGER.equals(paramType)) { if (value == null) { statement.setNull(i + 1, Types.INTEGER); } else { statement.setInt(i + 1, (Integer) value); } } else if (Parameter.TYPE_INPUTSTREAM.equals(paramType)) { if (value instanceof FileInputStream) { FileInputStream fis = (FileInputStream) value; long len = 0; try { len = fis.getChannel().size(); } catch (IOException e) { log.warn(getLogPrefix() + "could not determine file size", e); } statement.setBinaryStream(i + 1, fis, (int) len); } else if (value instanceof ByteArrayInputStream) { ByteArrayInputStream bais = (ByteArrayInputStream) value; long len = bais.available(); statement.setBinaryStream(i + 1, bais, (int) len); } else { throw new SenderException(getLogPrefix() + "unknown inputstream [" + value.getClass() + "] for parameter [" + pv.getDefinition().getName() + "]"); } } else if ("string2bytes".equals(paramType)) { statement.setBytes(i + 1, ((String) value).getBytes()); } else if ("bytes".equals(paramType)) { statement.setBytes(i + 1, (byte[]) value); } else { statement.setString(i + 1, (String) value); } } }
From source file:com.streamsets.pipeline.stage.processor.parser.sql.SqlParserProcessor.java
private void resolveSchema(SchemaAndTable schemaAndTable) throws StageException { Map<String, Integer> columns = new HashMap<>(); String schema = schemaAndTable.getSchema(); String table = schemaAndTable.getTable(); try (Statement s = connection.createStatement()) { ResultSetMetaData md = s// ww w .java 2 s. c o m .executeQuery(Utils.format("SELECT * FROM {}{} WHERE 1 = 0", StringUtils.isNotEmpty(schema) ? "\"" + schema + "\"." : "", "\"" + table + "\"")) .getMetaData(); int colCount = md.getColumnCount(); for (int i = 1; i <= colCount; i++) { int colType = md.getColumnType(i); String colName = md.getColumnName(i); if (!configBean.caseSensitive) { colName = colName.toUpperCase(); } if (colType == Types.DATE || colType == Types.TIME || colType == Types.TIMESTAMP) { dateTimeColumns.computeIfAbsent(schemaAndTable, k -> new HashMap<>()); dateTimeColumns.get(schemaAndTable).put(colName, md.getColumnTypeName(i)); } if (colType == Types.DECIMAL || colType == Types.NUMERIC) { decimalColumns.computeIfAbsent(schemaAndTable, k -> new HashMap<>()).put(colName, new PrecisionAndScale(md.getPrecision(i), md.getScale(i))); } columns.put(md.getColumnName(i), md.getColumnType(i)); } tableSchemas.put(schemaAndTable, columns); } catch (SQLException ex) { throw new StageException(JDBC_00, configBean.hikariConfigBean.connectionString); } }
From source file:com.squid.core.domain.operators.ExtendedType.java
public static int FromTypeName(String SQLName) { if (SQLName.equals("ARRAY")) { return Types.ARRAY; }// w ww. ja v a 2s. c o m if (SQLName.equals("INTEGER")) { return Types.INTEGER; } if (SQLName.equals("BINARY")) { return Types.BINARY; } if (SQLName.equals("BIT")) { return Types.BIT; } if (SQLName.equals("BLOB")) { return Types.BLOB; } if (SQLName.equals("BOOLEAN")) { return Types.BOOLEAN; } if (SQLName.equals("CHAR")) { return Types.CHAR; } if (SQLName.equals("CLOB")) { return Types.CLOB; } if (SQLName.equals("DATALINK")) { return Types.DATALINK; } if (SQLName.equals("DATE")) { return Types.DATE; } if (SQLName.equals("DECIMAL")) { return Types.DECIMAL; } if (SQLName.equals("DOUBLE")) { return Types.DOUBLE; } if (SQLName.equals("FLOAT")) { return Types.FLOAT; } if (SQLName.equals("JAVA_OBJECT")) { return Types.JAVA_OBJECT; } if (SQLName.equals("LONGNVARCHAR")) { return Types.LONGNVARCHAR; } if (SQLName.equals("LONGVARBINARY")) { return Types.LONGVARBINARY; } if (SQLName.equals("NCHAR")) { return Types.NCHAR; } if (SQLName.equals("NCLOB")) { return Types.NCLOB; } if (SQLName.equals("UNDEFINED")) { return Types.OTHER; } if (SQLName.equals("NUMERIC")) { return Types.NUMERIC; } if (SQLName.equals("NVARCHAR")) { return Types.NVARCHAR; } if (SQLName.equals("REAL")) { return Types.REAL; } if (SQLName.equals("REF")) { return Types.REF; } if (SQLName.equals("ROWID")) { return Types.ROWID; } if (SQLName.equals("SMALLINT")) { return Types.SMALLINT; } if (SQLName.equals("SQLXML")) { return Types.SQLXML; } if (SQLName.equals("STRUCT")) { return Types.STRUCT; } if (SQLName.equals("TIME")) { return Types.TIME; } if (SQLName.equals("TIMESTAMP")) { return Types.TIMESTAMP; } if (SQLName.equals("TINYINT")) { return Types.TINYINT; } if (SQLName.equals("VARCHAR")) { return Types.VARCHAR; } if (SQLName.equals("VARBINARY")) { return Types.VARBINARY; } return Types.OTHER; }
From source file:jongo.jdbc.JDBCExecutor.java
/** * Utility method which registers in a CallableStatement object the different {@link jongo.jdbc.StoredProcedureParam} * instances in the given list. Returns a List of {@link jongo.jdbc.StoredProcedureParam} with all the OUT parameters * registered in the CallableStatement/*from ww w .j a va 2 s .c o m*/ * @param cs the CallableStatement object where the parameters are registered. * @param params a list of {@link jongo.jdbc.StoredProcedureParam} * @return a list of OUT {@link jongo.jdbc.StoredProcedureParam} * @throws SQLException if we fail to register any of the parameters in the CallableStatement */ private static List<StoredProcedureParam> addParameters(final CallableStatement cs, final List<StoredProcedureParam> params) throws SQLException { List<StoredProcedureParam> outParams = new ArrayList<StoredProcedureParam>(); int i = 1; for (StoredProcedureParam p : params) { final Integer sqlType = p.getType(); if (p.isOutParameter()) { l.debug("Adding OUT parameter " + p.toString()); cs.registerOutParameter(i++, sqlType); outParams.add(p); } else { l.debug("Adding IN parameter " + p.toString()); switch (sqlType) { case Types.BIGINT: case Types.INTEGER: case Types.TINYINT: // case Types.NUMERIC: cs.setInt(i++, Integer.valueOf(p.getValue())); break; case Types.DATE: cs.setDate(i++, (Date) JongoUtils.parseValue(p.getValue())); break; case Types.TIME: cs.setTime(i++, (Time) JongoUtils.parseValue(p.getValue())); break; case Types.TIMESTAMP: cs.setTimestamp(i++, (Timestamp) JongoUtils.parseValue(p.getValue())); break; case Types.DECIMAL: cs.setBigDecimal(i++, (BigDecimal) JongoUtils.parseValue(p.getValue())); break; case Types.DOUBLE: cs.setDouble(i++, Double.valueOf(p.getValue())); break; case Types.FLOAT: cs.setLong(i++, Long.valueOf(p.getValue())); break; default: cs.setString(i++, p.getValue()); break; } } } return outParams; }
From source file:org.springframework.jdbc.core.StatementCreatorUtils.java
private static void setValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable String typeName, @Nullable Integer scale, Object inValue) throws SQLException { if (inValue instanceof SqlTypeValue) { ((SqlTypeValue) inValue).setTypeValue(ps, paramIndex, sqlType, typeName); } else if (inValue instanceof SqlValue) { ((SqlValue) inValue).setValue(ps, paramIndex); } else if (sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR) { ps.setString(paramIndex, inValue.toString()); } else if (sqlType == Types.NVARCHAR || sqlType == Types.LONGNVARCHAR) { ps.setNString(paramIndex, inValue.toString()); } else if ((sqlType == Types.CLOB || sqlType == Types.NCLOB) && isStringValue(inValue.getClass())) { String strVal = inValue.toString(); if (strVal.length() > 4000) { // Necessary for older Oracle drivers, in particular when running against an Oracle 10 database. // Should also work fine against other drivers/databases since it uses standard JDBC 4.0 API. if (sqlType == Types.NCLOB) { ps.setNClob(paramIndex, new StringReader(strVal), strVal.length()); } else { ps.setClob(paramIndex, new StringReader(strVal), strVal.length()); }/*from w w w . j a va2 s. c o m*/ return; } else { // Fallback: setString or setNString binding if (sqlType == Types.NCLOB) { ps.setNString(paramIndex, strVal); } else { ps.setString(paramIndex, strVal); } } } else if (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) { if (inValue instanceof BigDecimal) { ps.setBigDecimal(paramIndex, (BigDecimal) inValue); } else if (scale != null) { ps.setObject(paramIndex, inValue, sqlType, scale); } else { ps.setObject(paramIndex, inValue, sqlType); } } else if (sqlType == Types.BOOLEAN) { if (inValue instanceof Boolean) { ps.setBoolean(paramIndex, (Boolean) inValue); } else { ps.setObject(paramIndex, inValue, Types.BOOLEAN); } } else if (sqlType == Types.DATE) { if (inValue instanceof java.util.Date) { if (inValue instanceof java.sql.Date) { ps.setDate(paramIndex, (java.sql.Date) inValue); } else { ps.setDate(paramIndex, new java.sql.Date(((java.util.Date) inValue).getTime())); } } else if (inValue instanceof Calendar) { Calendar cal = (Calendar) inValue; ps.setDate(paramIndex, new java.sql.Date(cal.getTime().getTime()), cal); } else { ps.setObject(paramIndex, inValue, Types.DATE); } } else if (sqlType == Types.TIME) { if (inValue instanceof java.util.Date) { if (inValue instanceof java.sql.Time) { ps.setTime(paramIndex, (java.sql.Time) inValue); } else { ps.setTime(paramIndex, new java.sql.Time(((java.util.Date) inValue).getTime())); } } else if (inValue instanceof Calendar) { Calendar cal = (Calendar) inValue; ps.setTime(paramIndex, new java.sql.Time(cal.getTime().getTime()), cal); } else { ps.setObject(paramIndex, inValue, Types.TIME); } } else if (sqlType == Types.TIMESTAMP) { if (inValue instanceof java.util.Date) { if (inValue instanceof java.sql.Timestamp) { ps.setTimestamp(paramIndex, (java.sql.Timestamp) inValue); } else { ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime())); } } else if (inValue instanceof Calendar) { Calendar cal = (Calendar) inValue; ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); } else { ps.setObject(paramIndex, inValue, Types.TIMESTAMP); } } else if (sqlType == SqlTypeValue.TYPE_UNKNOWN || (sqlType == Types.OTHER && "Oracle".equals(ps.getConnection().getMetaData().getDatabaseProductName()))) { if (isStringValue(inValue.getClass())) { ps.setString(paramIndex, inValue.toString()); } else if (isDateValue(inValue.getClass())) { ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime())); } else if (inValue instanceof Calendar) { Calendar cal = (Calendar) inValue; ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); } else { // Fall back to generic setObject call without SQL type specified. ps.setObject(paramIndex, inValue); } } else { // Fall back to generic setObject call with SQL type specified. ps.setObject(paramIndex, inValue, sqlType); } }