List of usage examples for org.springframework.jdbc.support.lob LobHandler getClobAsCharacterStream
Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException;
From source file:lcn.module.oltp.web.common.base.handler.AltibaseClobStringTypeHandler.java
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler) throws SQLException { StringBuffer read_data = new StringBuffer(""); int read_length; char[] buf = new char[1024]; Reader rd = lobHandler.getClobAsCharacterStream(rs, index); try {/*from ww w . j a v a2s . c om*/ while ((read_length = rd.read(buf)) != -1) { read_data.append(buf, 0, read_length); } } catch (IOException ie) { SQLException sqle = new SQLException(ie.getMessage()); throw sqle; // 2011.10.10 ? ? } finally { if (rd != null) { try { rd.close(); } catch (Exception ignore) { LOG.debug("IGNORE: " + ignore.getMessage()); } } } return read_data.toString(); //return lobHandler.getClobAsString(rs, index); }
From source file:org.osaf.cosmo.hibernate.CalendarClobType.java
/** * @param resultSet a JDBC result set// w w w . java 2 s .c o m * @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"); Reader reader = lobHandler.getClobAsCharacterStream(resultSet, columns[0]); if (reader == null) return null; Calendar calendar = null; try { calendar = CalendarUtils.parseCalendar(reader); } catch (ParserException e) { log.error("error parsing icalendar from db", e); // shouldn't happen because we always persist valid data throw new HibernateException("cannot parse icalendar stream"); } catch (IOException ioe) { throw new HibernateException("cannot read icalendar stream"); } finally { if (reader != null) try { reader.close(); } catch (Exception e) { } } return calendar; }
From source file:org.osaf.cosmo.hibernate.XmlClobType.java
protected Object nullSafeGetInternal(ResultSet resultSet, String[] columns, Object owner, LobHandler lobHandler) throws SQLException, HibernateException { if (columns == null || columns.length != 1) throw new HibernateException("Only one column name can be used for the " + getClass() + " user type"); Reader reader = lobHandler.getClobAsCharacterStream(resultSet, columns[0]); if (reader == null) return null; // don't throw an exception if the clob can't be parsed, because // otherwise this item will not be able to be loaded (thus, it won't be // able to be deleted) String clob = null;/*from w w w. j av a 2s.c o m*/ try { clob = IOUtils.toString(reader); } catch (Exception e) { log.error("Error reading XML clob", e); return null; } try { return DomReader.read(clob); } catch (Exception e) { log.error("Error deserializing XML clob '" + clob + "'", e); return null; } finally { if (reader != null) try { reader.close(); } catch (Exception e) { } } }