apache/shardingsphere · error · SQLFeatureNotSupportedException

getTypeMap

Error message

getTypeMap

What it means

ShardingSphere's JDBC driver does not implement the java.sql.Connection method getTypeMap (retrieving the type map used for custom SQL type <-> Java class mapping). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. Custom-type mapping for structured types is not part of ShardingSphere's feature set, so the accessor is permanently unsupported. The exception is thrown the moment the method is invoked on any connection produced by the ShardingSphere Driver.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java:69

    
    @Override
    public final CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException {
        throw new SQLFeatureNotSupportedException("prepareCall");
    }
    
    @Override
    public final String nativeSQL(final String sql) throws SQLException {
        throw new SQLFeatureNotSupportedException("nativeSQL");
    }
    
    @Override
    public final void abort(final Executor executor) throws SQLException {
        throw new SQLFeatureNotSupportedException("abort");
    }
    
    @Override
    public final Map<String, Class<?>> getTypeMap() throws SQLException {
        throw new SQLFeatureNotSupportedException("getTypeMap");
    }
    
    @Override
    public final void setTypeMap(final Map<String, Class<?>> map) throws SQLException {
        throw new SQLFeatureNotSupportedException("setTypeMap");
    }
    
    @Override
    public int getNetworkTimeout() throws SQLException {
        throw new SQLFeatureNotSupportedException("getNetworkTimeout");
    }
    
    @Override
    public void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {
        throw new SQLFeatureNotSupportedException("setNetworkTimeout");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Remove the getTypeMap() call; ShardingSphere cannot supply a type map.
  2. Keep a plain JDBC connection (separate DataSource) for code paths that depend on custom type maps.
  3. Unwrap the underlying driver connection and call getTypeMap() on it if per-backend type-map state is acceptable.
Defensive patterns

Strategy: try-catch

Validate before calling

boolean supportsOp = false;
try {
    connection.getMetaData(); // connection is alive
    // JDBC has no capability flag for individual methods; probe once per JVM:
    supportsOp = probeSupport(connection); // reflective/one-time guarded call
} catch (final SQLException ignored) {
}
// Simpler and recommended: capability-check by driver URL
boolean isShardingSphere = url.startsWith("jdbc:shardingsphere:");
if (isShardingSphere) {
    // skip the unsupported call, use the alternative API path
}

Try / catch

try {
    connection.getTypeMap(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
    // expected on ShardingSphere connections: fall back to supported API
    log.debug("Driver does not support getTypeMap, using fallback", e);
}

Prevention

When it happens

Trigger: Calling Connection.getTypeMap() on a ShardingSphere connection.

Common situations: Generic JDBC tools, ORMs, or mapping frameworks that read the type map while introspecting a connection; code ported from Oracle-style apps that use STRUCT type maps.

Related errors


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