{"record":{"id":"fd50921c2f58eb25","repo":"apache/shardingsphere","slug":"getdate","errorCode":null,"errorMessage":"getDate","messagePattern":"getDate","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":52,"sourceCode":"\n/**\n * Unsupported {@code ResultSet} methods for generated keys.\n */\npublic abstract class AbstractUnsupportedGeneratedKeysResultSet extends AbstractUnsupportedOperationResultSet {\n    \n    @Override\n    public final boolean getBoolean(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBoolean\");\n    }\n    \n    @Override\n    public final boolean getBoolean(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBoolean\");\n    }\n    \n    @Override\n    public final Date getDate(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getDate\");\n    }\n    \n    @Override\n    public final Date getDate(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getDate\");\n    }\n    \n    @Override\n    public final Date getDate(final int columnIndex, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getDate\");\n    }\n    \n    @Override\n    public final Date getDate(final String columnLabel, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getDate\");\n    }\n    \n    @Override","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L34-L70","documentation":"getDate(int columnIndex) is declared final and always throws in AbstractUnsupportedGeneratedKeysResultSet. GeneratedKeysResultSet only exposes string/numeric/object getters over the Comparable key values collected after INSERT, so java.sql.Date extraction is intentionally unimplemented.","triggerScenarios":"Calling rs.getDate(1) on the ResultSet returned by Statement.getGeneratedKeys() after an INSERT executed through the ShardingSphere driver.","commonSituations":"Generic insert-with-key helpers that materialize generated keys into various Java types (including Date for date-based primary keys). Code ported from MySQL Connector/J, which supports getDate on its generated-keys result set, breaking under jdbc:shardingsphere:.","solutions":["Use rs.getString(1) or rs.getObject(1) and convert to java.sql.Date explicitly (java.sql.Date.valueOf(String) or millis construction).","If the generated key is a date/timestamp string, retrieve it as String from the datasource directly (e.g. SELECT the computed key column) instead of getGeneratedKeys().","Wrap in try-catch for SQLFeatureNotSupportedException with a string-parse fallback."],"exampleFix":"// before\nDate d = rs.getDate(1);\n\n// after\nString raw = rs.getString(1);\nDate d = raw == null ? null : java.sql.Date.valueOf(raw);","handlingStrategy":"try-catch","validationCode":"Object key = rs.getObject(1);\nif (key instanceof java.util.Date) { /* convert via getTime() */ } else { /* parse getString(1) */ }","typeGuard":"static boolean supportsDateGetters(ResultSet rs) {\n    return !(rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\"));\n}","tryCatchPattern":"try {\n    d = rs.getDate(1);\n} catch (SQLFeatureNotSupportedException e) {\n    String raw = rs.getString(1);\n    d = raw == null ? null : java.sql.Date.valueOf(raw);\n}","preventionTips":["Avoid temporal getters on generated-key result sets under ShardingSphere.","Convert key strings to Date explicitly in one mapper utility.","For date-valued keys, SELECT the key column after insert instead of using getGeneratedKeys()."],"tags":["jdbc","shardingsphere","generated-keys","resultset","sql-feature-not-supported","date"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}