Example usage for org.springframework.jdbc.support.lob LobCreator setBlobAsBytes

List of usage examples for org.springframework.jdbc.support.lob LobCreator setBlobAsBytes

Introduction

In this page you can find the example usage for org.springframework.jdbc.support.lob LobCreator setBlobAsBytes.

Prototype

void setBlobAsBytes(PreparedStatement ps, int paramIndex, @Nullable byte[] content) throws SQLException;

Source Link

Document

Set the given content as bytes on the given statement, using the given parameter index.

Usage

From source file:alfio.manager.UploadedResourceManager.java

private static void setFileValues(PreparedStatement ps, LobCreator lobCreator,
        UploadBase64FileModification file, int baseIndex) throws SQLException {
    ps.setString(1, file.getName());/*w  w w.j  av a  2 s . c om*/

    ps.setLong(baseIndex + 1, file.getFile().length);
    lobCreator.setBlobAsBytes(ps, baseIndex + 2, file.getFile());
    ps.setString(baseIndex + 3, file.getType());
    ps.setString(baseIndex + 4, Json.GSON.toJson(getAttributes(file)));
}

From source file:org.sakaiproject.orm.ibatis.support.BlobByteArrayTypeHandler.java

protected void setParameterInternal(PreparedStatement ps, int index, Object value, String jdbcType,
        LobCreator lobCreator) throws SQLException {
    lobCreator.setBlobAsBytes(ps, index, (byte[]) value);
}

From source file:org.snaker.engine.spring.SpringJdbcAccess.java

public void saveProcess(final Process process) {
    super.saveProcess(process);
    if (process.getBytes() != null) {
        template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {

            protected void setValues(PreparedStatement ps, LobCreator lobCreator)
                    throws SQLException, DataAccessException {
                try {
                    lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
                    StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }//  w  w  w.  j  a va2 s  . c  o  m
            }
        });
    }
}

From source file:org.snaker.engine.spring.SpringJdbcAccess.java

public void updateProcess(final Process process) {
    super.updateProcess(process);
    if (process.getBytes() != null) {
        template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {

            protected void setValues(PreparedStatement ps, LobCreator lobCreator)
                    throws SQLException, DataAccessException {
                try {
                    lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
                    StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }/*from  w ww  . ja  v  a  2s  .c  om*/
            }
        });
    }
}

From source file:org.snaker.engine.access.spring.SpringJdbcAccess.java

@Override
public void saveProcess(final Process process) {
    super.saveProcess(process);
    if (process.getBytes() != null) {
        template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
            @Override//www. j a va2  s  .c o  m
            protected void setValues(PreparedStatement ps, LobCreator lobCreator)
                    throws SQLException, DataAccessException {
                try {
                    lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
                    StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

From source file:org.snaker.engine.access.spring.SpringJdbcAccess.java

@Override
public void updateProcess(final Process process) {
    super.updateProcess(process);
    if (process.getBytes() != null) {
        template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
            @Override//  w w  w. j  av  a  2s .  com
            protected void setValues(PreparedStatement ps, LobCreator lobCreator)
                    throws SQLException, DataAccessException {
                try {
                    lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
                    StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

From source file:alfio.manager.FileUploadManager.java

public String insertFile(UploadBase64FileModification file) {
    String digest = DigestUtils.sha256Hex(file.getFile());

    if (Integer.valueOf(1).equals(repository.isPresent(digest))) {
        return digest;
    }/*from  w  ww  .  j a  va  2  s. c o m*/

    LobHandler lobHandler = new DefaultLobHandler();

    jdbc.getJdbcOperations().execute(repository.uploadTemplate(),
            new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
                @Override
                protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
                    ps.setString(1, digest);
                    ps.setString(2, file.getName());
                    ps.setLong(3, file.getFile().length);
                    lobCreator.setBlobAsBytes(ps, 4, file.getFile());
                    ps.setString(5, file.getType());
                    ps.setString(6, Json.GSON.toJson(getAttributes(file)));
                }
            });
    return digest;
}

From source file:com.ttech.cordovabuild.domain.asset.AssetServiceImpl.java

@Override
public AssetRef save(final InputStream inputStream, String mimeType) {
    final AssetRef ref = new AssetRef();
    ref.setMimeType(mimeType);/*from   ww  w  . j a va2  s.c o m*/
    jdbcTemplate.execute("insert into ASSETS (uuid,data) values (?,?)",
            new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
                @Override
                protected void setValues(PreparedStatement ps, LobCreator lobCreator)
                        throws SQLException, DataAccessException {
                    ref.setUuid(UUID.randomUUID().toString());
                    ps.setString(1, ref.getUuid());
                    try {
                        lobCreator.setBlobAsBytes(ps, 2, ByteStreams.toByteArray(inputStream));
                    } catch (IOException e) {
                        throw new AssetCreationException(e);
                    }
                }
            });
    return ref;
}

From source file:org.sakaiproject.orm.ibatis.support.BlobSerializableTypeHandler.java

protected void setParameterInternal(PreparedStatement ps, int index, Object value, String jdbcType,
        LobCreator lobCreator) throws SQLException, IOException {

    if (value != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        try {/* w  w w.j av  a 2 s  .co  m*/
            oos.writeObject(value);
            oos.flush();
            lobCreator.setBlobAsBytes(ps, index, baos.toByteArray());
        } finally {
            oos.close();
        }
    } else {
        lobCreator.setBlobAsBytes(ps, index, null);
    }
}

From source file:com.suntek.gztpb.dao.VehicleLicenseDao.java

public void saveApply(final VehicleLicenseModel apply, final byte[] fileStream) {
    String sql = "INSERT INTO itms_vehicle_license_apply_tmp (APPLYNUM,"
            + "BIZTYPE, SERVICEITEMNUM, BIZREASON, OWNERNAME, HOMEADDRESS, ZIP, EMAIL, PHONE,"
            + " MOBILE, IDTYPE, IDNO, SEX, BIRTHDAY, NATIVEPLACE, IGAMA, PLATENUMTYPE, PLATENUM,"
            + "VEHICLEIDNUM, ENGINENUM, VEHICLEIMAGE, PROXYFLAG, PROXYNAME,"
            + "PROXYADDRESS, PROXYZIP, PROXYPHONE, PROXYEMAIL, RECEIVETYPE, RECEIVER, RECEIVEADDRESS, RECEIVEPHONE,"
            + "CREATOR, CREATEDTIME, SOURCE) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate, ?)";
    getJdbcTemplate().execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) {
        protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
            ps.setString(1, apply.getApplyNum());
            ps.setString(2, apply.getBizType());
            ps.setString(3, apply.getSERVICEITEMNUM());
            ps.setString(4, apply.getBizReason());
            ps.setString(5, apply.getOwnerName());
            ps.setString(6, apply.getHomeAddress());
            ps.setString(7, apply.getZip());
            ps.setString(8, apply.getEmail());
            ps.setString(9, apply.getPhone());

            ps.setString(10, apply.getMobile());
            ps.setInt(11, apply.getIdType());
            ps.setString(12, apply.getIdNO());
            ps.setInt(13, apply.getSex());
            ps.setString(14, apply.getBirthday());
            ps.setString(15, apply.getNATIVEPLACE());
            ps.setString(16, apply.getIGAMA());
            ps.setString(17, apply.getPlateNumType());
            ps.setString(18, apply.getPlateNum());

            ps.setString(19, apply.getVehicleIdNum());
            ps.setString(20, apply.getengineNum());
            // ps.setString(21, apply.getVehicleImage());
            lobCreator.setBlobAsBytes(ps, 21, fileStream);
            ps.setInt(22, apply.getProxyFlag());
            // ps.setString(23, apply.getLetterOfAuth());
            ps.setString(23, apply.getPROXYNAME());

            ps.setString(24, apply.getPROXYADDRESS());
            ps.setString(25, apply.getPROXYzip());
            ps.setString(26, apply.getPROXYphone());
            ps.setString(27, apply.getPROXYemail());
            ps.setInt(28, apply.getReceiveType());
            ps.setString(29, apply.getReceiver());
            ps.setString(30, apply.getReceiveAddress());
            ps.setString(31, apply.getReceivePhone());
            ps.setString(32, apply.getCreator());
            //  ps.setDate(35, java.sql.Date.valueOf("2012-08-17"));// apply.getCreatedTime().toString()
            ps.setInt(33, apply.getSource());// 
            // ps.setString(37,"2012-09-09");//apply.getSUBMITTIME()
        }/*from  w w  w. j av a  2  s  . co m*/
    });
}