Java 8 Clob - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Clob class.

This code example shows how to use the following methods: getSubString, length
	@Override 
	public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
		logger.debug("Returning CLOB as string");
		if (this.wrapAsLob) {
			Clob clob = rs.getClob(columnIndex);
			return clob.getSubString(1, (int) clob.length());
		} 
		else { 
			return rs.getString(columnIndex);
		} 
	} 
 
	@Override 
	public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException {
		logger.debug("Returning CLOB as ASCII stream");
		if (this.wrapAsLob) {
			Clob clob = rs.getClob(columnIndex);
			return clob.getAsciiStream();
		} 
		else { 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCharacterStream
    public Object get(ResultSet rs, String colName) throws SQLException {
        File f = this.createTempFile();
        Clob clob = rs.getClob(colName);
        if (clob == null)
            return null; 
        Streams.writeAndClose(Streams.fileOutw(f), clob.getCharacterStream());
        return new SimpleClob(f);
    } 
 
    public void set(PreparedStatement stat, Object obj, int i) throws SQLException {
        if (null == obj) {
            stat.setNull(i, Types.CLOB);
        } else { 
            Clob clob = (Clob) obj;
            stat.setClob(i, clob);
        } 
    } 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: length
	 * @return String 
	 */ 
	private static String formatLogParam(Clob obj) {
		String result="";
		try { 
			result= "(cblob of length "+obj.length()+")";
		} catch (SQLException e) {
			result = "(cblob of unknown length)";
		} 
		return result;
	} 
 
	/** Formatter for debugging purposes only.  
	 * @param obj to print 
	 * @return String 
	 */ 
	private static String formatLogParam(Array obj) {
		String result="";
		try { 
			result= "(array of type"+obj.getBaseTypeName().length()+")";
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCharacterStream, length
		if (clob == null)
			return null; 
		 
		Reader reader = null;
		try { 
			reader = clob.getCharacterStream();
			char[] buffer = new char[(int)clob.length()];
			reader.read(buffer);
			return new String(buffer);
		} catch (IOException e) {
			throw new RuntimeException(e);
		} 
		finally { 
			try {reader.close();} catch (IOException e) {throw new RuntimeException(e);}
		} 
	} 
	 
	/* backup before use columnType 
	@SuppressWarnings({"rawtypes", "unchecked"}) 
	static final <T> List<T> build(ResultSet rs, Class<? extends Model> modelClass) throws SQLException, InstantiationException, IllegalAccessException { 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: free, getSubString, length
        if (val instanceof Clob) {
            Clob clobVal = (Clob)val;
            try 
            { 
                try { 
                    return clobVal.getSubString(1, (int)clobVal.length());
                } catch (SQLException e) {
                    throw new ConverterException("error converting clob to String", e);
                } 
            } finally { 
                try { 
                    clobVal.free();
                } catch (Throwable ignore) {
                    //ignore 
                } 
            } 
        } 
 
        if(val instanceof Reader){
            Reader reader = (Reader) val;
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 Clob Methods: