apache/shardingsphere · error · SQLFeatureNotSupportedException

createArrayOf

Error message

createArrayOf

What it means

ShardingSphere's JDBC driver does not implement the java.sql.Connection method createArrayOf (creating an java.sql.Array object for sending SQL ARRAY values to the database). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. Array typed values are not supported by ShardingSphere's parameter rewriting pipeline, so the factory method always throws. 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:89

    
    @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
    public Array createArrayOf(final String typeName, final Object[] elements) throws SQLException {
        throw new SQLFeatureNotSupportedException("createArrayOf");
    }
    
    @Override
    public final Blob createBlob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createBlob");
    }
    
    @Override
    public Clob createClob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createClob");
    }
    
    @Override
    public final NClob createNClob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createNClob");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Rewrite the query to avoid SQL arrays: expand values with IN-lists, use ANY/ARRAY literals inline in SQL text, or move array handling into application code.
  2. For PostgreSQL specifically, use string_agg/array_to_string-style SQL, or pass arrays as formatted literal strings with ::cast in the SQL.
  3. Unwrap the underlying connection (e.g. connection.unwrap(PgConnection.class)) and create the Array on it, then set it on the ShardingSphere PreparedStatement only if array parameters actually pass through your version's pipeline - verify with sql-show before relying on it.
  4. Point the array-dependent code path at a separate native DataSource.
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.createArrayOf(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
    // expected on ShardingSphere connections: fall back to supported API
    log.debug("Driver does not support createArrayOf, using fallback", e);
}

Prevention

When it happens

Trigger: Calling Connection.createArrayOf(typeName, elements) on a ShardingSphere connection (usually before PreparedStatement.setArray).

Common situations: PostgreSQL applications binding array parameters (e.g. integer[] in ANY(...) queries); ORMs (Hibernate array types, jOOQ ARRAY binding) that construct java.sql.Array via this factory; batch code migrating from the native pgjdbc driver.

Related errors


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