{"record":{"id":"f010a8ace04cebb3","repo":"apache/shardingsphere","slug":"setnstring","errorCode":null,"errorMessage":"setNString","messagePattern":"setNString","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationPreparedStatement.java","lineNumber":49,"sourceCode":"\n/**\n * Unsupported {@code PreparedStatement} methods.\n */\npublic abstract class AbstractUnsupportedOperationPreparedStatement extends AbstractStatementAdapter implements PreparedStatement {\n    \n    @Override\n    public final void addBatch(final String sql) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"addBatch sql in PreparedStatement\");\n    }\n    \n    @Override\n    public final ResultSetMetaData getMetaData() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getMetaData\");\n    }\n    \n    @Override\n    public final void setNString(final int parameterIndex, final String x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNString\");\n    }\n    \n    @Override\n    public final void setNClob(final int parameterIndex, final NClob x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNClob\");\n    }\n    \n    @Override\n    public final void setNClob(final int parameterIndex, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNClob\");\n    }\n    \n    @Override\n    public final void setNClob(final int parameterIndex, final Reader x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNClob\");\n    }\n    \n    @Override","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationPreparedStatement.java#L31-L67","documentation":"SQLFeatureNotSupportedException('setNString') thrown by AbstractUnsupportedOperationPreparedStatement.setNString(int, String). N-prefixed JDBC methods target SQL NATIONAL CHARACTER (NCHAR/NVARCHAR) columns; ShardingSphere's parameter pipeline passes plain objects to routed backend statements and has no N-type handling, so the final override always throws.","triggerScenarios":"ps.setNString(1, value) on a ShardingSphere PreparedStatement; typically from Oracle/SQLServer-oriented code targeting NVARCHAR/NCHAR columns, or ORMs that auto-select setNString for nationalized @Nationalized/@Type mappings.","commonSituations":"Apps written against Oracle NCHAR/NVARCHAR2 or SQL Server nvarchar schemas then pointed at jdbc:shardingsphere:; Hibernate entities annotated @Nationalized; code following JDBC tutorials for internationalized text.","solutions":["Replace with ps.setString(index, value); virtually all backends implicitly convert VARCHAR literals to N-columns.","In Hibernate, remove @Nationalized (or set hibernate.use_nationalized_character_data=false globally).","Ensure server/driver encoding (e.g. MySQL utf8mb4, PostgreSQL UTF8) makes N-types unnecessary."],"exampleFix":"// before\nps.setNString(1, name);\n\n// after\nps.setString(1, name);","handlingStrategy":"validation","validationCode":"// Replace every N-variant with the plain one before running on ShardingSphere\nps.setString(index, value); // instead of ps.setNString(index, value)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep for setN when adopting the ShardingSphere driver","Disable Hibernate @Nationalized / use_nationalized_character_data","Rely on UTF-8 database encoding instead of N-types"],"tags":["jdbc","shardingsphere","preparedstatement","nstring","sql-feature-not-supported"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}