I have problem for bulk insert of the file.I am saving the multiple record in mysql database with GWT from server side helper class.In that helper class, I have method for saving multiple record of the report object which is my domain class.Lets see code snippet below
while (iterator.hasNext()) {
Report report = (Report) iterator.next();
preparedStatment.setString(1, report.getTitle());
preparedStatment.setString(2, report.getReportAbstract());
preparedStatment.setString(3, report.getUrl());
preparedStatment.setDate(4,(java.sql.Date) report.getPublishDate());
preparedStatment.setString(5, report.getAuthor());
preparedStatment.setString(6, report.getPublisher());
preparedStatment.setDouble(7, report.getPrice());
preparedStatment.setString(8, report.getCurrency());
preparedStatment.setBoolean(9, report.isPurchase());
**preparedStatment.setBinaryStream(10, inpStream,(int)inputFile.length());**
preparedStatment.setString(11, report.getMimeType());
preparedStatment.setBoolean(12, report.isDownload());
preparedStatment.setLong(13, report.getReportSource());
preparedStatment.setDate(14, new java.sql.Date(date.getTime()));
preparedStatment.setBoolean(15, report.isDeleted());
preparedStatment.addBatch();
}
int[] updateCounts = preparedStatment.executeBatch();
connection.commit();
In the above code,the line in bold font for sending file for insert.I looping and inserting one by one record.but It only insert file for first record in database and for remaining record that field is empty i.e no file insertion but all fields are inserted properly.I stuck here for inserting file field for all record.
Can anybody please help me on this?
I don’t know your full code. You can try the following code,
and then in the Iterator just put the below code as a static one and lets see. If it works fine then pbm with your code only. Check the code before the Iterator.
Correct me if i’m wrong..