/** * [#2534] Extract <code>byte[]</code> or <code>String</code> data from a * LOB, if the argument is a lob. */ private static final Object unlob(Object object) throws SQLException { if (object instanceof Blob) { Blob blob = (Blob) object; try { return blob.getBytes(1, (int) blob.length()); } finally { JDBCUtils.safeFree(blob); } } else if (object instanceof Clob) { Clob clob = (Clob) object; try { return clob.getSubString(1, (int) clob.length()); } finally { JDBCUtils.safeFree(clob); } } return object; } }
@Override public final void get(BindingGetResultSetContext<String> ctx) throws SQLException { Clob clob = ctx.resultSet().getClob(ctx.index()); try { ctx.value(clob == null ? null : clob.getSubString(1, (int) clob.length())); } finally { JDBCUtils.safeFree(clob); } }
@Override public final void get(BindingGetResultSetContext<byte[]> ctx) throws SQLException { Blob blob = ctx.resultSet().getBlob(ctx.index()); try { ctx.value(blob == null ? null : blob.getBytes(1, (int) blob.length())); } finally { JDBCUtils.safeFree(blob); } }
@Override public final void get(BindingGetSQLInputContext<String> ctx) throws SQLException { Clob clob = ctx.input().readClob(); try { ctx.value(clob == null ? null : clob.getSubString(1, (int) clob.length())); } finally { JDBCUtils.safeFree(clob); } }
@Override public final void get(BindingGetSQLInputContext<byte[]> ctx) throws SQLException { Blob blob = ctx.input().readBlob(); try { ctx.value(blob == null ? null : blob.getBytes(1, (int) blob.length())); } finally { JDBCUtils.safeFree(blob); } }
@Override public final void get(BindingGetStatementContext<String> ctx) throws SQLException { Clob clob = ctx.statement().getClob(ctx.index()); try { ctx.value(clob == null ? null : clob.getSubString(1, (int) clob.length())); } finally { JDBCUtils.safeFree(clob); } }
@Override public final void get(BindingGetStatementContext<byte[]> ctx) throws SQLException { Blob blob = ctx.statement().getBlob(ctx.index()); try { ctx.value(blob == null ? null : blob.getBytes(1, (int) blob.length())); } finally { JDBCUtils.safeFree(blob); } }
safeFree(array);