public String deleteData(String resultSetID, SimpleJdbcTemplate template) { int id = 0, idPar = 0; CommonDAO.setDbmsClientInfo(template, userId); log.info("******************ENTERED DELETE"); id = template.update( "DELETE FROM LAU_SAVED_QUERY_RESULTS WHERE QUERY_RESULT_SET_ID = ?", resultSetID); idPar = template.update( "DELETE FROM LAU_QUERY_RESULT_SETS WHERE QUERY_RESULT_SET_ID = ?", resultSetID); log.info("LauSaveResultSetDAO delete() ID Child -> " + id + " Parent -> " + idPar); return String.valueOf(idPar); }
public String updateData( String resultSetID, String resultsetname, String resultdesc, String resultPermission, String reportids, String repFlag, String queryID, SimpleJdbcTemplate template, Timestamp dstamp) throws Exception { PreparedStatement ps1 = null; PreparedStatement ps2 = null; ApplicationContext ctx = AppContext.getApplicationContext(); com.nrg.lau.dao.SharedConnectionDAO shConnection = (com.nrg.lau.dao.SharedConnectionDAO) ctx.getBean("getSharedConnection"); Connection con = shConnection.getConVerify(); String success = ""; // queryID = ""; try { int idchild = 0; String sqlParent = "UPDATE LAU_QUERY_RESULT_SETS SET QUERY_ID=?,RESULT_SET_NAME=?," + "RESULT_SET_DESCRIPTION=?,CREATE_USER_ID=?, CREATE_TIMESTAMP=?, UPDATE_USER_ID=?, UPDATE_TIMESTAMP=?, RESULT_SET_PERMISSION=? WHERE QUERY_RESULT_SET_ID=?"; log.info("queryRsltID------------" + resultSetID); log.info("queryID----------------" + queryID); log.info("resultsetname----------" + resultsetname); log.info("resultdesc-------------" + resultdesc); log.info("resultPermission-------------" + resultPermission); log.info("userId-----------------" + userId); log.info("dt---------------------" + dstamp); ps1 = con.prepareStatement(sqlParent); ps1.setString(1, queryID); ps1.setString(2, resultsetname); ps1.setString(3, resultdesc); ps1.setString(4, userId); ps1.setObject(5, dstamp); ps1.setString(6, userId); ps1.setObject(7, dstamp); ps1.setString(8, resultPermission); ps1.setString(9, resultSetID); ps1.addBatch(); CommonDAO.setDbmsClientInfo(template, userId); log.info("******************DELETING Saved ResultSet"); idchild = template.update( "DELETE FROM LAU_SAVED_QUERY_RESULTS WHERE QUERY_RESULT_SET_ID = ?", resultSetID); log.info("LauSaveResultSetDAO delete() ID Child -> " + idchild); // INSERTING THE SavedResultSet Content ps2 = con.prepareStatement(sqlChild); String strReportIds = reportids; String[] reportIdArray = strReportIds.split(","); for (int i = 0; i < reportIdArray.length; i++) { String rprtId = reportIdArray[i]; Long rptId = Long.valueOf(rprtId); // log.info(" rptId-----------"+rptId); ps2.setString(1, resultSetID); ps2.setLong(2, rptId); ps2.setString(3, repFlag); ps2.setString(4, userId); ps2.setObject(5, dstamp); ps2.addBatch(); } log.info(" Start Batch execute------------------------------------------------"); int[] rtn1 = ps1.executeBatch(); ps1.close(); log.info(" END executeBatch 1------------------------------------------------:"); log.info(" START executeBatch Child------------------------------------------------:"); int[] rtn2 = ps2.executeBatch(); log.info(" Update length---------" + rtn2.length); log.info(" Update data##### " + rtn2[0]); success = Integer.toString(rtn2[0]); ps2.close(); log.info(" END executeBatch 2Child------------------------------------------------:"); } catch (Exception e) { log.error("IN --" + e); con.rollback(); log.error("IN -- Rollback---"); throw new Exception(e); } finally { try { try { if (ps2 != null) ps2.close(); } catch (Exception e) { log.error(e, e); } } catch (Exception e) { log.error("Error -- " + e); } } return success; }