Search in sources :

Example 1 with NClob

use of java.sql.NClob in project druid by alibaba.

the class StatFilter method buildSlowParameters.

private String buildSlowParameters(StatementProxy statement) {
    JSONWriter out = new JSONWriter();
    out.writeArrayStart();
    for (int i = 0, parametersSize = statement.getParametersSize(); i < parametersSize; ++i) {
        JdbcParameter parameter = statement.getParameter(i);
        if (i != 0) {
            out.writeComma();
        }
        if (parameter == null) {
            continue;
        }
        Object value = parameter.getValue();
        if (value == null) {
            out.writeNull();
        } else if (value instanceof String) {
            String text = (String) value;
            if (text.length() > 100) {
                out.writeString(text.substring(0, 97) + "...");
            } else {
                out.writeString(text);
            }
        } else if (value instanceof Number) {
            out.writeObject(value);
        } else if (value instanceof java.util.Date) {
            out.writeObject(value);
        } else if (value instanceof Boolean) {
            out.writeObject(value);
        } else if (value instanceof InputStream) {
            out.writeString("<InputStream>");
        } else if (value instanceof NClob) {
            out.writeString("<NClob>");
        } else if (value instanceof Clob) {
            out.writeString("<Clob>");
        } else if (value instanceof Blob) {
            out.writeString("<Blob>");
        } else {
            out.writeString('<' + value.getClass().getName() + '>');
        }
    }
    out.writeArrayEnd();
    return out.toString();
}
Also used : JSONWriter(com.alibaba.druid.support.json.JSONWriter) NClob(java.sql.NClob) Blob(java.sql.Blob) JdbcParameter(com.alibaba.druid.proxy.jdbc.JdbcParameter) Date(java.util.Date) InputStream(java.io.InputStream) Savepoint(java.sql.Savepoint) NClob(java.sql.NClob) Clob(java.sql.Clob)

Example 2 with NClob

use of java.sql.NClob in project druid by alibaba.

the class ConnectionProxyImpl method createNClob.

@Override
public NClob createNClob() throws SQLException {
    FilterChainImpl chain = createChain();
    NClob value = chain.connection_createNClob(this);
    recycleFilterChain(chain);
    return value;
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) NClob(java.sql.NClob)

Example 3 with NClob

use of java.sql.NClob in project druid by alibaba.

the class ResultSetProxyImpl method getNClob.

@Override
public NClob getNClob(int columnIndex) throws SQLException {
    FilterChainImpl chain = createChain();
    NClob value = chain.resultSet_getNClob(this, columnIndex);
    recycleFilterChain(chain);
    return value;
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) NClob(java.sql.NClob)

Example 4 with NClob

use of java.sql.NClob in project hibernate-orm by hibernate.

the class ContextualLobCreator method createNClob.

@Override
public NClob createNClob(String string) {
    try {
        final NClob nclob = createNClob();
        nclob.setString(1, string);
        return nclob;
    } catch (SQLException e) {
        throw new JDBCException("Unable to set NCLOB string afterQuery creation", e);
    }
}
Also used : NClob(java.sql.NClob) JDBCException(org.hibernate.JDBCException) SQLException(java.sql.SQLException)

Example 5 with NClob

use of java.sql.NClob in project hibernate-orm by hibernate.

the class LobCreatorTest method testLobCreation.

private void testLobCreation(LobCreator lobCreator) throws SQLException {
    Blob blob = lobCreator.createBlob(new byte[] {});
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(blob instanceof BlobImplementer);
    } else {
        assertTrue(blob instanceof JdbcBlob);
    }
    blob = lobCreator.wrap(blob);
    assertTrue(blob instanceof WrappedBlob);
    Clob clob = lobCreator.createClob("Hi");
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(clob instanceof ClobImplementer);
    } else {
        assertTrue(clob instanceof JdbcClob);
    }
    clob = lobCreator.wrap(clob);
    assertTrue(clob instanceof WrappedClob);
    Clob nclob = lobCreator.createNClob("Hi");
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(nclob instanceof NClobImplementer);
    } else {
        assertTrue(nclob instanceof JdbcNClob);
    }
    assertTrue(NClob.class.isInstance(nclob));
    nclob = lobCreator.wrap(nclob);
    assertTrue(nclob instanceof WrappedClob);
    blob.free();
    clob.free();
    nclob.free();
}
Also used : WrappedBlob(org.hibernate.engine.jdbc.WrappedBlob) NClob(java.sql.NClob) WrappedBlob(org.hibernate.engine.jdbc.WrappedBlob) Blob(java.sql.Blob) WrappedClob(org.hibernate.engine.jdbc.WrappedClob) NClobImplementer(org.hibernate.engine.jdbc.NClobImplementer) BlobImplementer(org.hibernate.engine.jdbc.BlobImplementer) ClobImplementer(org.hibernate.engine.jdbc.ClobImplementer) NClobImplementer(org.hibernate.engine.jdbc.NClobImplementer) WrappedClob(org.hibernate.engine.jdbc.WrappedClob) NClob(java.sql.NClob) Clob(java.sql.Clob)

Aggregations

NClob (java.sql.NClob)11 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)5 Clob (java.sql.Clob)5 Blob (java.sql.Blob)4 Connection (java.sql.Connection)3 ResultSet (java.sql.ResultSet)3 MockNClob (com.alibaba.druid.mock.MockNClob)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 JdbcParameter (com.alibaba.druid.proxy.jdbc.JdbcParameter)1 JSONWriter (com.alibaba.druid.support.json.JSONWriter)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 Writer (java.io.Writer)1 PreparedStatement (java.sql.PreparedStatement)1 SQLXML (java.sql.SQLXML)1 Savepoint (java.sql.Savepoint)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1