public void saveAttachments(FileData[] files) throws SQLException,
SystemException {
Connection connection = this.dataSource.getConnection();
PreparedStatement st = connection.prepareStatement(dbDriver
.getQueries().getForumQueries().getSql_ADD_ATTACH_INFO());
IFileProcessor fProc = getFileProcessor(IFileProcConst.ATTACH_FILE_PROCESSOR);
try {
for (int i = 0; i < files.length; i++) {
int id = ((Integer) keyGen.generateKey(
IKeyGenConst.KEY_NAMES[IKeyGenConst.KEY_ATTACH],
connection)).intValue();
FileData fd = files[i];
st.setInt(1, id);
st.setString(2, fd.getInfo().getContentType());
st.setString(3, fd.getInfo().getName());
st.setString(4, fd.getInfo().getDescription());
st.setInt(5, fd.getInfo().getSize());
st.setInt(6, fd.getInfo().getMessageId());
st.execute();
fProc.saveFileData(fd.getData(),
IFileProcConst.ATTACH_KEY_PREFIX + id);
}
} finally {
st.close();
connection.close();