in pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java [932:1004]
public void setObject(@Positive int parameterIndex, @Nullable Object x) throws SQLException {
checkClosed();
if (x == null) {
setNull(parameterIndex, Types.OTHER);
} else if (x instanceof UUID && connection.haveMinimumServerVersion(ServerVersion.v8_3)) {
setUuid(parameterIndex, (UUID) x);
} else if (x instanceof SQLXML) {
setSQLXML(parameterIndex, (SQLXML) x);
} else if (x instanceof String) {
setString(parameterIndex, (String) x);
} else if (x instanceof BigDecimal) {
setBigDecimal(parameterIndex, (BigDecimal) x);
} else if (x instanceof Short) {
setShort(parameterIndex, (Short) x);
} else if (x instanceof Integer) {
setInt(parameterIndex, (Integer) x);
} else if (x instanceof Long) {
setLong(parameterIndex, (Long) x);
} else if (x instanceof Float) {
setFloat(parameterIndex, (Float) x);
} else if (x instanceof Double) {
setDouble(parameterIndex, (Double) x);
} else if (x instanceof byte[]) {
setBytes(parameterIndex, (byte[]) x);
} else if (x instanceof ByteStreamWriter) {
setByteStreamWriter(parameterIndex, (ByteStreamWriter) x);
} else if (x instanceof java.sql.Date) {
setDate(parameterIndex, (java.sql.Date) x);
} else if (x instanceof Time) {
setTime(parameterIndex, (Time) x);
} else if (x instanceof Timestamp) {
setTimestamp(parameterIndex, (Timestamp) x);
} else if (x instanceof Boolean) {
setBoolean(parameterIndex, (Boolean) x);
} else if (x instanceof Byte) {
setByte(parameterIndex, (Byte) x);
} else if (x instanceof Blob) {
setBlob(parameterIndex, (Blob) x);
} else if (x instanceof Clob) {
setClob(parameterIndex, (Clob) x);
} else if (x instanceof Array) {
setArray(parameterIndex, (Array) x);
} else if (x instanceof PGobject) {
setPGobject(parameterIndex, (PGobject) x);
} else if (x instanceof Character) {
setString(parameterIndex, ((Character) x).toString());
} else if (x instanceof java.time.LocalDate) {
setDate(parameterIndex, (java.time.LocalDate) x);
} else if (x instanceof java.time.LocalTime) {
setTime(parameterIndex, (java.time.LocalTime) x);
} else if (x instanceof java.time.LocalDateTime) {
setTimestamp(parameterIndex, (java.time.LocalDateTime) x);
} else if (x instanceof java.time.OffsetDateTime) {
setTimestamp(parameterIndex, (java.time.OffsetDateTime) x);
} else if (x instanceof Map) {
setMap(parameterIndex, (Map<?, ?>) x);
} else if (x instanceof Number) {
setNumber(parameterIndex, (Number) x);
} else if (x.getClass().isArray()) {
try {
setObjectArray(parameterIndex, x);
} catch (Exception e) {
throw new PSQLException(
GT.tr("Cannot cast an instance of {0} to type {1}", x.getClass().getName(), "Types.ARRAY"),
PSQLState.INVALID_PARAMETER_TYPE, e);
}
} else {
// Can't infer a type.
throw new PSQLException(GT.tr(
"Can''t infer the SQL type to use for an instance of {0}. Use setObject() with an explicit Types value to specify the type to use.",
x.getClass().getName()), PSQLState.INVALID_PARAMETER_TYPE);
}
}