@Override public LobCreator getLobCreator() { return (this.createTemporaryLob ? new TemporaryLobCreator() : new DefaultLobCreator()); }
/** * Create a new CLOB value with the given character stream. * @param reader the character stream containing the CLOB value * @param length the length of the CLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(Reader reader, int length, LobHandler lobHandler) { this.content = reader; this.length = length; this.lobCreator = lobHandler.getLobCreator(); }
/** * Create a new BLOB/CLOB value with the given stream, * using a DefaultLobHandler. * @param stream the stream containing the LOB value * @param length the length of the LOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(InputStream stream, int length) { this(stream, length, new DefaultLobHandler()); }
@Override public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { LobCreator lobCreator = this.lobHandler.getLobCreator(); try { setValues(ps, lobCreator); return ps.executeUpdate(); } finally { lobCreator.close(); } }
@Test public void test4() throws SQLException { String testContent = "Bla"; SqlLobValue lob = new SqlLobValue(testContent, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); verify(creator).setClobAsString(preparedStatement, 1, testContent); }
/** * Close the LobCreator, if any. */ @Override public void cleanup() { this.lobCreator.close(); }
@Test public void testGetBlobAsBytes() throws SQLException { lobHandler.getBlobAsBytes(rs, 1); verify(rs).getBytes(1); }
@Override public Reader getClobAsCharacterStream(ResultSet rs, String columnName) throws SQLException { return getClobAsCharacterStream(rs, rs.findColumn(columnName)); }
@Override @Nullable public byte[] getBlobAsBytes(ResultSet rs, String columnName) throws SQLException { return getBlobAsBytes(rs, rs.findColumn(columnName)); }
@Override @Nullable public InputStream getClobAsAsciiStream(ResultSet rs, String columnName) throws SQLException { return getClobAsAsciiStream(rs, rs.findColumn(columnName)); }
@Override @Nullable public InputStream getBlobAsBinaryStream(ResultSet rs, String columnName) throws SQLException { return getBlobAsBinaryStream(rs, rs.findColumn(columnName)); }
@Override @Nullable public String getClobAsString(ResultSet rs, String columnName) throws SQLException { return getClobAsString(rs, rs.findColumn(columnName)); }
@Test public void testGetClobAsCharacterStream() throws SQLException { lobHandler.getClobAsCharacterStream(rs, 1); verify(rs).getCharacterStream(1); }
@Test public void testGetClobAsAsciiStream() throws SQLException { lobHandler.getClobAsAsciiStream(rs, 1); verify(rs).getAsciiStream(1); }
/** * Create a new BLOB/CLOB value with the given stream. * @param stream the stream containing the LOB value * @param length the length of the LOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(InputStream stream, int length, LobHandler lobHandler) { this.content = stream; this.length = length; this.lobCreator = lobHandler.getLobCreator(); }
/** * Create a new CLOB value with the given character stream, * using a DefaultLobHandler. * @param reader the character stream containing the CLOB value * @param length the length of the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(Reader reader, int length) { this(reader, length, new DefaultLobHandler()); }
/** * Create a new BLOB value with the given byte array. * @param bytes the byte array containing the BLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(@Nullable byte[] bytes, LobHandler lobHandler) { this.content = bytes; this.length = (bytes != null ? bytes.length : 0); this.lobCreator = lobHandler.getLobCreator(); }
/** * Create a new BLOB value with the given byte array, * using a DefaultLobHandler. * @param bytes the byte array containing the BLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable byte[] bytes) { this(bytes, new DefaultLobHandler()); }
/** * Create a new CLOB value with the given content string. * @param content the String containing the CLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(@Nullable String content, LobHandler lobHandler) { this.content = content; this.length = (content != null ? content.length() : 0); this.lobCreator = lobHandler.getLobCreator(); }
/** * Create a new CLOB value with the given content string, * using a DefaultLobHandler. * @param content the String containing the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable String content) { this(content, new DefaultLobHandler()); }