I am trying to insert record in child table in MySQL using JDBC. But not able to get inserted id of parent table. Below is my code:
con = DAOManager.getConnection();
con.setAutoCommit(false);
voucherArgs.add(voucher.getVendorId());
voucherArgs.add(voucher.getDate());
voucherArgs.add(voucher.getDiscount());
voucherArgs.add(voucher.getDiscountAmount());
voucherArgs.add(voucher.getSubTotal());
voucherArgs.add(voucher.getTotalAmount());
voucherArgs.add(voucher.getInvoice());
voucherArgs.add(voucher.getEmployeeId());
String sqlString = "INSERT INTO recieving_voucher (I_VENDOR,D_VOUCHER,DISCOUNT,DISCOUNT_AMT,SUB_TOTAL,n"
+ "TOTAL_AMT,INVOICE,I_EMPLOYEE) VALUES (?,?,?,?,?,?,?,?)";
//insert voucher entry
SQLExecutor.insertOrUpdate(sqlString, voucherArgs, con);
Integer maxId = (Integer) SQLExecutor.executeQueryWithoutArguments("SELECT MAX(I_RCV_VOUCHER) FROM recieving_voucher ", new GetIntHandler());
Aucun commentaire:
Enregistrer un commentaire