日期:2014-05-18 浏览次数:20831 次
org.apache.commons.dbcp.DelegatingPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V
int fileSize = 1024 * 1000;
Employee employee = employeeDao.get(Employee.class, employeeId);
EmployeeFace employeeFace = new EmployeeFace();
String faceId = UUID.randomUUID().toString().replace("-", "");
byte[] bytes = new byte[fileSize];
try {
FileInputStream stream = new FileInputStream(faceFile);
ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
for (int n; (n = stream.read(bytes)) != -1;) {
out.write(bytes, 0, n);
}
stream.close();
out.close();
LobHelper lobHelper = employeeFaceDao.getCurrentSession().getLobHelper();
employeeFace.setId(faceId);
employeeFace.setImage(lobHelper.createBlob(bytes));
PojoUtil.fillSystemProperties(employeeFace);
employeeFaceDao.save(employeeFace);
employee.setFace(faceId);
PojoUtil.fillSystemProperties(employee);
employeeDao.update(employee);
} catch (Exception e) {
e.printStackTrace();
return false;
}