{"record":{"id":"13c271b3a70c40d6","repo":"apache/shardingsphere","slug":"setclientinfo-name-value","errorCode":null,"errorMessage":"setClientInfo name value","messagePattern":"setClientInfo name value","errorType":"exception","errorClass":"UnsupportedSQLOperationException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java","lineNumber":129,"sourceCode":"    \n    @Override\n    public final Struct createStruct(final String typeName, final Object[] attributes) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"createStruct\");\n    }\n    \n    @Override\n    public final Properties getClientInfo() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getClientInfo\");\n    }\n    \n    @Override\n    public final String getClientInfo(final String name) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getClientInfo name\");\n    }\n    \n    @Override\n    public final void setClientInfo(final String name, final String value) {\n        throw new UnsupportedSQLOperationException(\"setClientInfo name value\");\n    }\n    \n    @Override\n    public final void setClientInfo(final Properties props) {\n        throw new UnsupportedSQLOperationException(\"setClientInfo properties\");\n    }\n}\n","sourceCodeStart":111,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java#L111-L137","documentation":"ShardingSphere's JDBC driver does not implement the java.sql.Connection method setClientInfo name value (setting a single named JDBC 4 client info property (e.g. ApplicationName, ClientUser) on the connection). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. ShardingSphere deliberately rejects client-info mutation with UnsupportedSQLOperationException (an SQLFeatureNotSupportedException subtype without checked wrapping semantics), so the single-property setter always throws. The exception is thrown the moment the method is invoked on any connection produced by the ShardingSphere Driver.","triggerScenarios":"Calling Connection.setClientInfo(name, value) on a ShardingSphere connection.","commonSituations":"APM agents (Datadog, Elastic, New Relic) stamping connection names at checkout; connection pools propagating end-user identity; SQL Server/PostgreSQL users setting ApplicationName for sys.dm_exec_sessions/pg_stat_activity visibility.","solutions":["Remove the setClientInfo call when running behind ShardingSphere, or wrap it in a tolerant catch.","Set the equivalent backend property in the storage-unit JDBC URL (e.g. PostgreSQL ApplicationName=..., MySQL connectionAttributes) so it reaches the real connections.","Unwrap the underlying driver connection and call setClientInfo on it directly, accepting per-backend rather than per-logical-connection semantics."],"exampleFix":"// before\nconnection.setClientInfo(\"ApplicationName\", \"billing-service\");\n\n// after (set it on the backend URL instead)\n// url: jdbc:postgresql://db-host:5432/app?ApplicationName=billing-service\n// or unwrap the real connection:\ntry {\n    connection.setClientInfo(\"ApplicationName\", \"billing-service\");\n} catch (final SQLException ignored) {\n    // ShardingSphere driver does not support client info\n}","handlingStrategy":"try-catch","validationCode":"boolean supportsOp = false;\ntry {\n    connection.getMetaData(); // connection is alive\n    // JDBC has no capability flag for individual methods; probe once per JVM:\n    supportsOp = probeSupport(connection); // reflective/one-time guarded call\n} catch (final SQLException ignored) {\n}\n// Simpler and recommended: capability-check by driver URL\nboolean isShardingSphere = url.startsWith(\"jdbc:shardingsphere:\");\nif (isShardingSphere) {\n    // skip the unsupported call, use the alternative API path\n}","typeGuard":null,"tryCatchPattern":"try {\n    connection.setClientInfo(/* args */);\n} catch (final SQLFeatureNotSupportedException e) {\n    // expected on ShardingSphere connections: fall back to supported API\n    log.debug(\"Driver does not support setClientInfo name value, using fallback\", e);\n}","preventionTips":["Put ApplicationName and similar markers in the backend JDBC URL (e.g. ?ApplicationName=...) rather than calling setClientInfo on the logical connection.","Catch SQLFeatureNotSupportedException around agent-installed client-info stamping.","Check the JDBC URL before calling optional JDBC 4 methods: connections starting with jdbc:shardingsphere: never support the lob/network-timeout/client-info/callable APIs.","Catch java.sql.SQLFeatureNotSupportedException (parent of ShardingSphere's UnsupportedSQLOperationException) around optional driver-capability calls so the application degrades gracefully."],"tags":["jdbc","shardingsphere","unsupported-operation","connection-api"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}