sql = "INSERT INTO LOG_FILENAME(ID,FILENAME,CREATETIME) VALUES(2,?,sysdate)";
public void batchInsertFileNames(File[] files) throws SQLException {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = (PreparedStatement) conn.prepareStatement(sql);
Date date = new Date();
for (int i = 0; i < files.length; i++) {
setParams(pstmt, files[i].getName(), date);
}
pstmt.executeBatch();
} finally {
DbUtils.close(pstmt);
}
}
private void setParams(PreparedStatement pstmt, String fileName, Date date)
throws SQLException {
pstmt.setString(1, fileName);
pstmt.addBatch();
}