{"record":{"id":"5d89e2b7a325a8fd","repo":"apache/shardingsphere","slug":"gettimestamp","errorCode":null,"errorMessage":"getTimestamp","messagePattern":"getTimestamp","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":92,"sourceCode":"    \n    @Override\n    public final Time getTime(final int columnIndex, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTime\");\n    }\n    \n    @Override\n    public final Time getTime(final String columnLabel, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTime\");\n    }\n    \n    @Override\n    public final Time getTime(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTime\");\n    }\n    \n    @Override\n    public final Timestamp getTimestamp(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTimestamp\");\n    }\n    \n    @Override\n    public final Timestamp getTimestamp(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTimestamp\");\n    }\n    \n    @Override\n    public final Timestamp getTimestamp(final int columnIndex, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTimestamp\");\n    }\n    \n    @Override\n    public final Timestamp getTimestamp(final String columnLabel, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTimestamp\");\n    }\n    \n    @Override","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L74-L110","documentation":"getTimestamp(int columnIndex) is final and always throws SQLFeatureNotSupportedException in AbstractUnsupportedGeneratedKeysResultSet. Although GeneratedKeysResultSet stores Comparable values (which could be timestamps), it implements only getString/getNumeric/getObject accessors, and Timestamp extraction is deliberately delegated to the unsupported base class.","triggerScenarios":"Calling rs.getTimestamp(1) on the ResultSet from Statement.getGeneratedKeys() after an INSERT via the ShardingSphere driver.","commonSituations":"Insert helpers mapping generated keys to Timestamp-typed ids (e.g. MongoDB ObjectId-adjacent patterns or timestamp-based keys), or generic mappers copying vendor-driver behavior. Common when porting MySQL Connector/J code that supports getTimestamp on generated keys.","solutions":["Use rs.getString(1) and convert with java.sql.Timestamp.valueOf(String) when the key is a timestamp literal.","Use rs.getObject(1) and convert via ((java.util.Date) obj).getTime() or Timestamp.valueOf(obj.toString()).","For numeric keys use getLong/getBigDecimal instead.","Catch SQLFeatureNotSupportedException and fall back to string parsing."],"exampleFix":"// before\nTimestamp ts = rs.getTimestamp(1);\n\n// after\nString raw = rs.getString(1);\nTimestamp ts = raw == null ? null : java.sql.Timestamp.valueOf(raw);","handlingStrategy":"try-catch","validationCode":"Object key = rs.getObject(1); // timestamp keys arrive as Comparable; convert from runtime type","typeGuard":"static boolean isShardingGeneratedKeys(ResultSet rs) {\n    return rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    ts = rs.getTimestamp(1);\n} catch (SQLFeatureNotSupportedException e) {\n    Object v = rs.getObject(1);\n    ts = v == null ? null : java.sql.Timestamp.valueOf(v.toString());\n}","preventionTips":["Read generated keys with getLong/getBigDecimal/getString/getObject only.","Convert timestamp-like keys via Timestamp.valueOf of the string form.","Include getGeneratedKeys flows in driver-migration test suites."],"tags":["jdbc","shardingsphere","generated-keys","resultset","sql-feature-not-supported","timestamp"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}