All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nimbusds.infinispan.persistence.sql.transformers.SQLServerNVarcharBinding Maven / Gradle / Ivy

package com.nimbusds.infinispan.persistence.sql.transformers;


import org.jooq.*;
import org.jooq.conf.ParamType;
import org.jooq.impl.DSL;

import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Types;


/**
 * Microsoft SQL server NVARCHAR binding, prefixed 'N' to inline string values.
 *
 * 

Used https://github.com/jOOQ/jOOQ/issues/7825 */ public class SQLServerNVarcharBinding implements Binding { @Override public Converter converter() { return new StringToStringConverter(); } @Override public void sql(final BindingSQLContext ctx) { if (ctx.render().paramType() == ParamType.INLINED) { // Prefix value with 'N' for UTF16 // https://github.com/jOOQ/jOOQ/issues/9548 ctx.render().sql((ctx.value() != null ? "N" : "")).visit(DSL.inline(ctx.value())); } else { ctx.render().sql("?"); } } // Registering NVARCHAR types for JDBC CallableStatement OUT parameters @Override public void register(final BindingRegisterContext ctx) throws SQLException { ctx.statement().registerOutParameter(ctx.index(), Types.NVARCHAR); } // Converting the String value and setting that on a JDBC PreparedStatement @Override public void set(final BindingSetStatementContext ctx) throws SQLException { ctx.statement().setNString(ctx.index(), ctx.value()); } // Getting a String value from a JDBC ResultSet and converting that to a JsonElement @Override public void get(final BindingGetResultSetContext ctx) throws SQLException { ctx.convert(converter()).value(ctx.resultSet().getNString(ctx.index())); } // Getting a String value from a JDBC CallableStatement @Override public void get(final BindingGetStatementContext ctx) throws SQLException { ctx.convert(converter()).value(ctx.statement().getNString(ctx.index())); } // Getting a value from a JDBC SQLInput (useful for Oracle OBJECT types) @Override public void get(final BindingGetSQLInputContext ctx) throws SQLException { throw new SQLFeatureNotSupportedException(); } // Setting a value on a JDBC SQLOutput (useful for Oracle OBJECT types) @Override public void set(final BindingSetSQLOutputContext ctx) throws SQLException { throw new SQLFeatureNotSupportedException(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy