{"record":{"id":"91ae85ec8ccb673e","repo":"apache/shardingsphere","slug":"only-named-savepoint-are-supported","errorCode":null,"errorMessage":"Only named savepoint are supported.","messagePattern":"Only named savepoint are supported\\.","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"warning","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java","lineNumber":47,"sourceCode":" * ShardingSphere savepoint.\n */\n@Getter\npublic final class ShardingSphereSavepoint implements Savepoint {\n    \n    private final String savepointName;\n    \n    public ShardingSphereSavepoint() {\n        savepointName = UUID.randomUUID().toString().replaceAll(\"-\", \"_\");\n    }\n    \n    public ShardingSphereSavepoint(final String savepointName) throws SQLException {\n        ShardingSpherePreconditions.checkNotEmpty(savepointName, () -> new SQLFeatureNotSupportedException(\"Savepoint name can not be NULL or empty\"));\n        this.savepointName = savepointName;\n    }\n    \n    @Override\n    public int getSavepointId() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"Only named savepoint are supported.\");\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":50,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java#L29-L50","documentation":"SQLFeatureNotSupportedException from ShardingSphereSavepoint.getSavepointId(): ShardingSphere implements only named savepoints (a UUID- or user-supplied name); the JDBC numeric-savepoint API is deliberately unsupported, so asking for an id always throws.","triggerScenarios":"Calling getSavepointId() on a Savepoint returned by Connection.setSavepoint() through the ShardingSphere driver. Note setSavepoint() (no-arg, numeric savepoints) itself is also unsupported — callers must use setSavepoint(String name).","commonSituations":"Generic transaction-management or ORM code that branches on savepoint type and queries getSavepointId(); frameworks written against drivers that support numeric savepoints (MySQL/PostgreSQL native drivers do).","solutions":["Always create savepoints with a name: conn.setSavepoint(\"my-savepoint\").","In generic code, check getSavepointName() availability or catch SQLFeatureNotSupportedException and fall back to named handling.","Avoid calling getSavepointId() on savepoints obtained from ShardingSphere connections."],"exampleFix":"// before\nSavepoint sp = conn.setSavepoint();\nint id = sp.getSavepointId(); // throws\n// after\nSavepoint sp = conn.setSavepoint(\"sp_before_bulk\");\nString name = sp.getSavepointName();","handlingStrategy":"try-catch","validationCode":"if (savepoint instanceof ShardingSphereSavepoint) { name = ((ShardingSphereSavepoint) savepoint).getSavepointName(); }","typeGuard":null,"tryCatchPattern":"try { sp.getSavepointId(); } catch (SQLFeatureNotSupportedException ex) { use sp.getSavepointName(); }","preventionTips":["Always use setSavepoint(String)","Never call setSavepoint() (no-arg) on ShardingSphere connections","Write framework code that prefers named savepoints"],"tags":["jdbc","savepoint","transaction","unsupported-feature"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}