tursodatabase/turso · error · SQLException
Unsupported object type in setObject: {type}
Error message
Unsupported object type in setObject: {type} What it means
The catch-all else of setObject(int, Object): the value's runtime class matches none of the supported types (null, String, Integer, Long, Boolean, Double, Float, Byte, Short, byte[], Timestamp, java.sql.Date, Time, BigDecimal). Common Java types that land here include java.time LocalDate/LocalDateTime/Instant, UUID, BigInteger, enums, and any custom value object. The message embeds the exact class that failed.
Source
Thrown at bindings/java/src/main/java/tech/turso/jdbc4/JDBC4PreparedStatement.java:315
} else if (x instanceof byte[]) {
setBytes(parameterIndex, (byte[]) x);
} else if (x instanceof Timestamp) {
setTimestamp(parameterIndex, (Timestamp) x);
} else if (x instanceof Date) {
setDate(parameterIndex, (Date) x);
} else if (x instanceof Time) {
setTime(parameterIndex, (Time) x);
} else if (x instanceof BigDecimal) {
setBigDecimal(parameterIndex, (BigDecimal) x);
} else if (x instanceof Blob
|| x instanceof Clob
|| x instanceof InputStream
|| x instanceof Reader) {
throw new SQLException(
"setObject does not yet support LOB or Stream types because the corresponding set methods are unimplemented. Type found: "
+ x.getClass().getName());
} else {
throw new SQLException("Unsupported object type in setObject: " + x.getClass().getName());
}
}
@Override
public boolean execute() throws SQLException {
return execute(currentBatchParams);
}
/** This helper method runs the statement using the provided parameter values. */
private boolean execute(Object[] params) throws SQLException {
// TODO: check whether this is sufficient
requireNonNull(statement);
bindParams(params);
boolean result = statement.execute();
updateCount = statement.changes();
return result;
}
View on GitHub (pinned to bad083fafb)
Solutions
- Convert before binding: LocalDate -> java.sql.Date.valueOf(ld); Instant -> Timestamp.from(i); LocalDateTime -> Timestamp.valueOf(ldt); UUID -> u.toString() (or 16-byte array); enum -> name().
- Use the typed setters (setString, setLong, ...) instead of setObject where possible.
- In generic layers, register a converter per domain type and fail fast on unmapped classes.
Example fix
// before ps.setObject(1, LocalDate.of(2024, 1, 31)); // throws // after ps.setObject(1, java.sql.Date.valueOf(LocalDate.of(2024, 1, 31)));
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = toSupportedType(raw); // LocalDate->Date, Instant->Timestamp, UUID->String, enum->name()
if (v != null && !isSetObjectSupported(v)) {
throw new IllegalArgumentException("Unsupported bind type: " + v.getClass().getName());
}
ps.setObject(i, v); Type guard
static boolean isSetObjectSupported(Object x) {
return x == null || x instanceof String || x instanceof Boolean
|| x instanceof Byte || x instanceof Short || x instanceof Integer
|| x instanceof Long || x instanceof Float || x instanceof Double
|| x instanceof byte[] || x instanceof java.sql.Timestamp
|| x instanceof java.sql.Date || x instanceof java.sql.Time
|| x instanceof java.math.BigDecimal;
} Try / catch
catch (SQLException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unsupported object type in setObject")) {
// map the named class to a supported type (java.time -> java.sql, UUID -> String) and retry
}
throw e;
} Prevention
- Convert java.time values to java.sql types at your persistence boundary; never rely on setObject pass-through.
- Keep UUID and enum encodings (TEXT vs byte[]) explicit and consistent.
- Write one exhaustive binder switch over types so new types fail in tests, not production.
When it happens
Trigger: ps.setObject(1, LocalDate.now()); ps.setObject(1, UUID.randomUUID()); ps.setObject(1, MyEnum.A); ps.setObject(1, BigInteger.TEN); any POJO passed as a parameter.
Common situations: Modern java.time code against a JDBC4-era driver that only knows java.sql date/time classes; ORMs storing UUID primary keys as objects; migrating from PostgreSQL's permissive setObject which accepts nearly anything.
Related errors
- Unsupported object type in bindObject: " + x.getClass().getN
- setObject does not yet support LOB or Stream types because t
- Cannot convert value to Date: {type}
- Cannot convert value to Timestamp: {type}
- Cannot convert to ASCII stream: {type}
AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16).
Data as JSON: /api/errors/a85340492df966ef.
Report an issue: GitHub.