Code example for ResultSet

Methods: getBlob

0
        suffix = ".blob"; 
    } 
 
    public Object get(ResultSet rs, String colName) throws SQLException {
        File f = this.createTempFile();
        Blob blob = rs.getBlob(colName);
        if (blob == null)
            return null; 
        Files.write(f, blob.getBinaryStream());
        return new SimpleBlob(f);
    } 
 
    public void set(PreparedStatement stat, Object obj, int i) throws SQLException {
        if (null == obj) {
            stat.setNull(i, Types.BLOB);
        } else { 
            Blob blob = (Blob) obj;
            stat.setBlob(i, blob);
        } 
    }