2
在Xls文件中我有下面的代碼上傳下面的方法調用,直到XLS的最後一行&我正在將值追加到StringBuilder。StringBuilder()追加在最後一次迭代的交易ID
public boolean insertBatch(Connection con, int projectId, int venueId, String batchName, String examStartDate, String examStartTime, String examEndTime, String reportingStartTime, String reportingEndTime, int totalSeats) {
String this.query = new StringBuilder().append("insert into venue_batch (batch_code ,exam_venue_id ,exam_date ,exam_start_time ,exam_end_time ,reporting_start_time ,reporting_end_time ,total_seats,tranID) VALUES ('").append(batchName).append("' ,").append(venueId).append(" ,'").append(stDate).append("' ,'").append(examStartTime).append("' ,'").append(examEndTime).append("' ,'").append(reportingStartTime).append("' ,'").append(reportingEndTime).append("' ,").append(totalSeats).append(")").toString();
try {
this.stmt = con.createStatement();
count = this.stmt.executeUpdate(this.query);
this.stmt.close();
} catch (SQLException ex) {
System.out.println(new StringBuilder().append("Venue # insertBatch # SQLException").append(ex.toString()).toString());
onUploadFail(con, "Please try again!");
}
}
*I need to add Unique Transaction id(VenueTranId) to DB at the last during executeUpdate(this.query), in the above Query how to Proceed below is Transaction id code.Thanks All..
Calendar calendar = Calendar.getInstance();
Long lngTime = Long.valueOf(calendar.getTimeInMillis());
String VenueTranId=lngTime.toString();
我試着理解你對StringBuilder的驚人使用,並對你正在做的事情有一種感覺。我放棄。你能簡化一點嗎? – Steve