{"record":{"id":"b8e0d6b4ba7efe36","repo":"apache/shardingsphere","slug":"getboolean","errorCode":null,"errorMessage":"getBoolean","messagePattern":"getBoolean","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":42,"sourceCode":"import java.sql.Blob;\nimport java.sql.Clob;\nimport java.sql.Date;\nimport java.sql.SQLException;\nimport java.sql.SQLFeatureNotSupportedException;\nimport java.sql.SQLWarning;\nimport java.sql.SQLXML;\nimport java.sql.Time;\nimport java.sql.Timestamp;\nimport java.util.Calendar;\n\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","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L24-L60","documentation":"AbstractUnsupportedGeneratedKeysResultSet makes getBoolean(int columnIndex) final and always throwing. The ResultSet returned by Statement.getGeneratedKeys() in the ShardingSphere driver is a GeneratedKeysResultSet holding plain Comparable key values (usually numeric auto-increment ids) and only implements string/numeric/object getters, so there is no boolean conversion path.","triggerScenarios":"Executing an INSERT through the ShardingSphere driver with Statement.RETURN_GENERATED_KEYS, then calling rs.getBoolean(1) while iterating the ResultSet from getGeneratedKeys().","commonSituations":"Generic key-mapping frameworks or copy-pasted DAO code that reads every generated key with getBoolean regardless of key type. Migrating working code from a native MySQL/PostgreSQL driver to jdbc:shardingsphere: where the vendor result set silently coerced values to boolean.","solutions":["Use the supported getter matching real key types: rs.getLong(1), rs.getInt(1), rs.getBigDecimal(1), or rs.getString(1).","Use rs.getObject(1) and convert in Java if the key type varies (e.g. ((Number) obj).longValue()).","Remove the getBoolean branch for generated-key result sets; auto-increment keys are never boolean.","As a last resort wrap in try-catch for SQLFeatureNotSupportedException and re-read via getString."],"exampleFix":"// before\nboolean ok = rs.getBoolean(1);\n\n// after\nlong id = rs.getLong(1);","handlingStrategy":"try-catch","validationCode":"// Generated keys are scalar; before reading, choose a supported getter:\nObject key = rs.getObject(1); // never throws SQLFeatureNotSupportedException here","typeGuard":"static boolean isShardingGeneratedKeys(ResultSet rs) {\n    return rs instanceof org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet\n        || rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    flag = rs.getBoolean(1);\n} catch (SQLFeatureNotSupportedException e) {\n    flag = rs.getLong(1) != 0; // or parse rs.getString(1)\n}","preventionTips":["Read generated keys with getLong/getInt/getBigDecimal/getString/getObject only.","Never assume boolean coercion of generated keys; keys are ids, not flags.","Unit-test key-mapping code with the ShardingSphere driver on the classpath."],"tags":["jdbc","shardingsphere","generated-keys","resultset","sql-feature-not-supported","boolean"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}