apache/shardingsphere · warning · SQLFeatureNotSupportedException

Only named savepoint are supported.

Error message

Only named savepoint are supported.

What it means

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.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java:47

 * ShardingSphere savepoint.
 */
@Getter
public final class ShardingSphereSavepoint implements Savepoint {
    
    private final String savepointName;
    
    public ShardingSphereSavepoint() {
        savepointName = UUID.randomUUID().toString().replaceAll("-", "_");
    }
    
    public ShardingSphereSavepoint(final String savepointName) throws SQLException {
        ShardingSpherePreconditions.checkNotEmpty(savepointName, () -> new SQLFeatureNotSupportedException("Savepoint name can not be NULL or empty"));
        this.savepointName = savepointName;
    }
    
    @Override
    public int getSavepointId() throws SQLException {
        throw new SQLFeatureNotSupportedException("Only named savepoint are supported.");
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Always create savepoints with a name: conn.setSavepoint("my-savepoint").
  2. In generic code, check getSavepointName() availability or catch SQLFeatureNotSupportedException and fall back to named handling.
  3. Avoid calling getSavepointId() on savepoints obtained from ShardingSphere connections.

Example fix

// before
Savepoint sp = conn.setSavepoint();
int id = sp.getSavepointId(); // throws
// after
Savepoint sp = conn.setSavepoint("sp_before_bulk");
String name = sp.getSavepointName();
Defensive patterns

Strategy: try-catch

Validate before calling

if (savepoint instanceof ShardingSphereSavepoint) { name = ((ShardingSphereSavepoint) savepoint).getSavepointName(); }

Try / catch

try { sp.getSavepointId(); } catch (SQLFeatureNotSupportedException ex) { use sp.getSavepointName(); }

Prevention

When it happens

Trigger: 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).

Common situations: 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).

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/91ae85ec8ccb673e. Report an issue: GitHub.