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 { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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);
        } 
    } 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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()+")";
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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 { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSubString, length
public class ClobSqlReturnType implements SqlReturnType { 
 
	@Override 
	public Object getTypeValue(CallableStatement cs, int paramIndex, int sqlType, String typeName) throws SQLException {
		Clob clob = cs.getClob(paramIndex);
		return clob != null ? clob.getSubString(1, (int) clob.length()) : null;
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsciiStream, getCharacterStream, getSubString, length
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSubString, length
  public String getNullableResult(ResultSet rs, String columnName)
      throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnName);
    if (clob != null) {
      int size = (int) clob.length();
      value = clob.getSubString(1, size);
    } 
    return value;
  } 
 
  @Override 
  public String getNullableResult(ResultSet rs, int columnIndex)
      throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnIndex);
    if (clob != null) {
      int size = (int) clob.length();
      value = clob.getSubString(1, size);
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getCharacterStream, length
			return; 
		} 
 
		Clob clob = ( Clob ) value;
 
		if ( WrappedClob.class.isInstance( clob ) ) {
			clob = ( (WrappedClob) value ).getWrappedClob();
		} 
 
		final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob()
				&& ClobImplementer.class.isInstance( clob );
 
		if ( useInputStream ) {
			st.setCharacterStream( index, clob.getCharacterStream(), (int) clob.length() );
		} 
		else { 
			st.setClob( index, clob );
		} 
	} 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSubString, length
  public String getNullableResult(ResultSet rs, String columnName)
      throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnName);
    if (clob != null) {
      int size = (int) clob.length();
      value = clob.getSubString(1, size);
    } 
    return value;
  } 
 
  @Override 
  public String getNullableResult(ResultSet rs, int columnIndex)
      throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnIndex);
    if (clob != null) {
      int size = (int) clob.length();
      value = clob.getSubString(1, size);
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 Clob Methods: