{"record":{"id":"4108585b7dc9de24","repo":"prestodb/presto","slug":"unsupported-object-type","errorCode":null,"errorMessage":"Unsupported object type: ","messagePattern":"Unsupported object type: ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java","lineNumber":433,"sourceCode":"            setBigDecimal(parameterIndex, (BigDecimal) x);\n        }\n        else if (x instanceof String) {\n            setString(parameterIndex, (String) x);\n        }\n        else if (x instanceof byte[]) {\n            setBytes(parameterIndex, (byte[]) x);\n        }\n        else if (x instanceof Date) {\n            setDate(parameterIndex, (Date) x);\n        }\n        else if (x instanceof Time) {\n            setTime(parameterIndex, (Time) x);\n        }\n        else if (x instanceof Timestamp) {\n            setTimestamp(parameterIndex, (Timestamp) x);\n        }\n        else {\n            throw new SQLException(\"Unsupported object type: \" + x.getClass().getName());\n        }\n    }\n\n    @Override\n    public void addBatch()\n            throws SQLException\n    {\n        checkOpen();\n        batchValues.add(toValues(parameters));\n        isBatch = true;\n    }\n\n    @Override\n    public void clearBatch()\n            throws SQLException\n    {\n        checkOpen();\n        batchValues.clear();","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java#L415-L451","documentation":"PrestoPreparedStatement.setObject only supports a fixed set of Java types (String, Boolean, numeric types, byte[], Date, Time, Timestamp, etc.). If the passed object's runtime type is not one of those, it throws a SQLException naming the actual class. Presto's JDBC driver has a narrow parameter type mapping, so arbitrary Java objects cannot be bound.","triggerScenarios":"Calling setObject(i, x) with an unsupported type such as BigDecimal? (supported), UUID, LocalDate, LocalDateTime, enum, or any custom POJO — any object not instanceof String, Boolean, Integer, Long, Double, Float, Short, Byte, byte[], BigDecimal, Date, Time, or Timestamp.","commonSituations":"Migrating code from drivers that support JDBC 4.2 java.time types (LocalDate/LocalDateTime) or ORM-generated parameter objects; passing UUID or enum values directly instead of converting them.","solutions":["Convert the value to a supported JDBC type before calling setObject (e.g. Date.from(localDate), Timestamp.valueOf(localDateTime), uuid.toString()).","Use the type-specific setter: setString for text/UUID, setLong/setInt for numbers, setTimestamp for instants.","Pass null via setNull(i, Types.X) when the value is null of unknown type.","Check the driver version; newer Presto/Trino JDBC drivers may accept java.time types via setObject."],"exampleFix":"// before\nUUID id = UUID.randomUUID();\nps.setObject(1, id);\n// after\nps.setString(1, id.toString());","handlingStrategy":"type-guard","validationCode":"private static final Set<Class<?>> SUPPORTED = Set.of(String.class, Boolean.class, Integer.class, Long.class, Short.class, Byte.class, Double.class, Float.class, byte[].class, java.math.BigDecimal.class, java.sql.Date.class, java.sql.Time.class, java.sql.Timestamp.class);\nif (x != null && !SUPPORTED.contains(x.getClass())) throw new IllegalArgumentException(\"convert type before setObject: \" + x.getClass());","typeGuard":"static boolean isSupportedParam(Object x) {\n    return x == null || x instanceof String || x instanceof Boolean || x instanceof Number\n        || x instanceof byte[] || x instanceof java.sql.Date || x instanceof java.sql.Time\n        || x instanceof java.sql.Timestamp || x instanceof java.math.BigDecimal;\n}","tryCatchPattern":"try { ps.setObject(i, x); } catch (SQLException e) { if (e.getMessage().startsWith(\"Unsupported object type\")) { ps.setString(i, String.valueOf(x)); } else throw e; }","preventionTips":["Always bind java.sql.Date/Time/Timestamp, not java.time types, with this driver","Convert UUID/enum/custom types to String or numeric before setObject","Check DatabaseMetaData/support for JDBC 4.2 java.time support before relying on setObject"],"tags":["jdbc","presto","type-mapping"],"backgroundTag":"unsupported-sql-object-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}