List of usage examples for org.springframework.jdbc.support.lob LobHandler getBlobAsBinaryStream
@Nullable InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException;
From source file:org.sakaiproject.orm.ibatis.support.BlobSerializableTypeHandler.java
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler) throws SQLException, IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, index); if (is != null) { ObjectInputStream ois = new ObjectInputStream(is); try {/*from w ww. j a v a 2 s . c o m*/ return ois.readObject(); } catch (ClassNotFoundException ex) { throw new SQLException("Could not deserialize BLOB contents: " + ex.getMessage()); } finally { ois.close(); } } else { return null; } }
From source file:org.osaf.cosmo.hibernate.BufferedContentBlob.java
/** * @param resultSet a JDBC result set/*from w w w .j a v a 2 s.com*/ * @param columns the column names * @param owner the containing entity * @param lobHandler the LobHandler to use */ protected Object nullSafeGetInternal(ResultSet resultSet, String[] columns, Object owner, LobHandler lobHandler) throws SQLException, HibernateException { // we only handle one column, so panic if it isn't so if (columns == null || columns.length != 1) throw new HibernateException("Only one column name can be used for the " + getClass() + " user type"); InputStream is = lobHandler.getBlobAsBinaryStream(resultSet, columns[0]); if (is == null) return null; BufferedContent content = null; try { content = new BufferedContent(is); } catch (IOException ioe) { throw new HibernateException("cannot read binary stream"); } finally { if (is != null) try { is.close(); } catch (Exception e) { } } return content; }