tursodatabase/turso · error · SQLFeatureNotSupportedException

createNClob not supported

Error message

createNClob not supported

What it means

Connection.createNClob() throws SQLFeatureNotSupportedException at JDBC4Connection.java:278. NClob is the national-character-set variant of Clob; the engine behind turso stores all text as UTF-8 and has no separate NCHAR LOB type, so the API is deliberately unimplemented. Use setString() for national character text as well.

Solutions

  1. Use ps.setNString(index, text) or ps.setString(index, text) - both store UTF-8 text natively.
  2. Remove @Nationalized/@Lob combos from Hibernate mappings and map to plain String over TEXT columns.
  3. Catch SQLFeatureNotSupportedException in shared layers and fall back to setNString.
  4. Remove all createNClob/setNClob(Clob) call sites; grep for 'NClob' during migrations.

Example fix

// before
NClob nclob = conn.createNClob(); // throws
nclob.setString(1, unicodeText);
ps.setNClob(1, nclob);

// after
ps.setNString(1, unicodeText);
Defensive patterns

Strategy: fallback

Validate before calling

// unicode text binds directly; no NClob needed
// ps.setNString(index, unicodeText) handles UTF-8 natively

Try / catch

try {
    NClob nclob = conn.createNClob();
    ps.setNClob(i, nclob);
} catch (SQLFeatureNotSupportedException e) {
    ps.setNString(i, unicodeText); // fallback binding
}

Prevention

When it happens

Trigger: conn.createNClob() followed by setNClob(...); Hibernate/JPA with @Nationalized annotations on large text fields; frameworks that prefer NClob for NString-typed parameters (JPA nationalized support); code ported from SQL Server nvarchar(max) patterns.

Common situations: Hibernate @Nationalized + @Lob String attributes; migrations from SQL Server where nvarchar(max) maps to NClob; generic ORM parameter binders that choose NClob for unicode columns; conformance suites that exercise the full JDBC 4 surface.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/2030d3e9dc38ef8b. Report an issue: GitHub.

Appendix: source

Thrown at bindings/java/src/main/java/tech/turso/jdbc4/JDBC4Connection.java:278

  @Override
  public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
    // TODO: maybe we can enhance this functionality by using columnNames
    return prepareStatement(sql);
  }

  @Override
  public Clob createClob() throws SQLException {
    throw new SQLFeatureNotSupportedException("createClob not supported");
  }

  @Override
  public Blob createBlob() throws SQLException {
    throw new SQLFeatureNotSupportedException("createBlob not supported");
  }

  @Override
  public NClob createNClob() throws SQLException {
    throw new SQLFeatureNotSupportedException("createNClob not supported");
  }

  @Override
  @SkipNullableCheck
  public SQLXML createSQLXML() throws SQLException {
    throw new SQLFeatureNotSupportedException("createSQLXML not supported");
  }

  @Override
  public boolean isValid(int timeout) throws SQLException {
    if (isClosed()) {
      return false;
    }

    try (Statement statement = createStatement()) {
      return statement.execute("select 1;");
    }
  }

View on GitHub (pinned to 244cde92a7)