List of usage examples for java.sql PreparedStatement setTimestamp
void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException;
java.sql.Timestamp
value. From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertVerblijfsobjecten(final List<Verblijfsobject> verblijfsobjecten) throws DAOException { try {//w ww. j av a 2 s. c om transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcTemplate.batchUpdate("insert into bag_verblijfsobject (" + "bag_verblijfsobject_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "verblijfsobject_geometrie," + "oppervlakte_verblijfsobject," + "verblijfsobject_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer," + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, verblijfsobjecten.get(i).getIdentificatie()); ps.setInt(2, verblijfsobjecten.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, verblijfsobjecten.get(i).getAanduidingRecordCorrectie()); ps.setInt(4, verblijfsobjecten.get(i).getOfficieel().ordinal()); ps.setString(5, verblijfsobjecten.get(i).getVerblijfsobjectGeometrie()); ps.setInt(6, verblijfsobjecten.get(i).getOppervlakteVerblijfsobject()); ps.setInt(7, verblijfsobjecten.get(i).getVerblijfsobjectStatus().ordinal()); ps.setTimestamp(8, new Timestamp( verblijfsobjecten.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (verblijfsobjecten.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(verblijfsobjecten.get(i) .getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, verblijfsobjecten.get(i).getInOnderzoek().ordinal()); ps.setDate(11, new Date(verblijfsobjecten.get(i).getDocumentdatum().getTime())); ps.setString(12, verblijfsobjecten.get(i).getDocumentnummer()); ps.setLong(13, verblijfsobjecten.get(i).getHoofdAdres()); } @Override public int getBatchSize() { return verblijfsobjecten.size(); } }); insertGebruikersdoelen(verblijfsobjecten); insertNevenadressen(TypeAdresseerbaarObject.VERBLIJFSOBJECT, verblijfsobjecten); insertGerelateerdePanden(verblijfsobjecten); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting verblijfsobjecten", e); } }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java
/** * @param geoId//from ww w. j av a2 s.co m * @param geonameId * @param rankId */ private void updateGeography(final int geoId, final int geonameId, final String newGeoName, final String newISOCode, final String[] parentNames) { boolean autoCommit = true; String oldName = querySingleObj(GEONAME_SQL + geoId); String sql = "SELECT asciiname, ISOCode FROM geoname WHERE geonameId = " + geonameId; Object[] row = geonameId != -1 ? queryForRow(sql) : null; if (row == null && !this.doAddISOCode) { return; } if (row != null || newISOCode != null) { String name = this.doUpdateName || row == null ? newGeoName : (String) row[0]; String isoCode = this.doAddISOCode && isNotEmpty(newISOCode) ? newISOCode : (String) row[1]; PreparedStatement pStmt = null; try { autoCommit = updateConn.getAutoCommit(); String pre = "UPDATE geography SET "; String post = ", ModifiedByAgentID=?, TimestampModified=? WHERE GeographyID=?"; int inx = 2; if (this.doUpdateName && this.doAddISOCode) { pStmt = updateConn.prepareStatement(pre + "Name=?, GeographyCode=?" + post); pStmt.setString(1, name); pStmt.setString(2, isoCode); inx = 3; } else if (this.doUpdateName) { pStmt = updateConn.prepareStatement(pre + "Name=? " + post); pStmt.setString(1, name.toLowerCase()); } else if (this.doAddISOCode) { pStmt = updateConn.prepareStatement(pre + "GeographyCode=? " + post); pStmt.setString(1, isoCode); } if (pStmt != null) { pStmt.setInt(inx, createdByAgent.getId()); pStmt.setTimestamp(inx + 1, new Timestamp(Calendar.getInstance().getTime().getTime())); pStmt.setInt(inx + 2, geoId); boolean isOK = true; int rv = pStmt.executeUpdate(); if (rv != 1) { log.error("Error updating " + name); isOK = false; } else { //areNodesChanged = true; // Global indication that at least one node was updated. totalUpdated++; } if (mergeToGeoId != null && doMerge) { sql = String.format("UPDATE locality SET GeographyID = %d WHERE GeographyID = %d", mergeToGeoId, geoId); if (update(sql) > 0) { sql = "DELETE FROM geography WHERE GeographyID = " + geoId; if (update(sql) != 1) { log.error("Unable to delete geo id " + geoId); } else { //areNodesChanged = true; totalMerged++; } } else { log.error(String.format("Unable to update localities from geo id %d to %d ", geoId, mergeToGeoId)); } } if (!autoCommit) { updateConn.commit(); } String nbsp = " "; tblWriter.log(parentNames[0] != null ? parentNames[0] : oldName, parentNames[1] != null ? parentNames[1] : nbsp, //parentNames[2] != null ? parentNames[2] : nbsp, // Counties doUpdateName ? oldName : nbsp, doUpdateName ? name : nbsp, doAddISOCode ? isoCode : nbsp, isOK ? "Updated" : "Error Updating."); } } catch (SQLException e) { e.printStackTrace(); if (!autoCommit) { try { updateConn.rollback(); } catch (SQLException e1) { e1.printStackTrace(); } } } finally { // These need to be reset here, // because this method is called sometimes automatically doUpdateName = false; doMerge = false; doAddISOCode = true; selectedSearchItem = null; try { if (pStmt != null) pStmt.close(); } catch (SQLException e) { e.printStackTrace(); } } } else { log.error("Couldn't find record: " + sql); } }
From source file:gov.nih.nci.cadsr.persist.de.Data_Elements_Mgr.java
/** * Updates single row of Data Element /*from w w w . j av a2 s.c om*/ * * @param deVO * @param conn * @throws DBException */ public void update(BaseVO vo, Connection conn) throws DBException { DeVO deVO = (DeVO) vo; PreparedStatement ps = null; deVO.setDeleted_ind(DBConstants.RECORD_DELETED_NO); deVO.setDate_modified(new java.sql.Timestamp(new java.util.Date().getTime())); // logger.debug("updateClient()"); try { StringBuffer sql = new StringBuffer(); sql.append(" update data_elements_view "); sql.append("set date_modified = ?"); sql.append(", modified_by = ?"); sql.append(", deleted_ind = ?"); if (deVO.getConte_IDSEQ() != null) { sql.append(", conte_idseq = ?"); } if (deVO.getPrefferred_name() != null) { sql.append(", preferred_name = ?"); } if (deVO.getVd_IDSEQ() != null) { sql.append(", vd_idseq = ?"); } if (deVO.getDec_IDSEQ() != null) { sql.append(", dec_idseq = ?"); } if (deVO.getPrefferred_def() != null) { sql.append(", preferred_definition = ?"); } if (deVO.getAsl_name() != null) { sql.append(", asl_name = ?"); } if (deVO.getLong_name() != null) { // allow null update sql.append(", long_name = ?"); } if (deVO.getLastest_version_ind() != null) { sql.append(", latest_version_ind = ?"); } if (deVO.getBegin_date() != null) { sql.append(", begin_date = ?"); } if (deVO.getEnd_date() != null) { sql.append(", end_date = ?"); } if (deVO.getChange_note() != null) { // allow null updates sql.append(", change_note = ?"); } if (deVO.getOrigin() != null) { // allow null updates sql.append(", origin= ?"); } sql.append(" where de_idseq = ?"); ps = conn.prepareStatement(sql.toString()); int placeIndicator = 1; //Here to account for dynamic sql ps.setTimestamp(placeIndicator++, deVO.getDate_modified()); ps.setString(placeIndicator++, deVO.getModified_by()); ps.setString(placeIndicator++, deVO.getDeleted_ind()); if (deVO.getConte_IDSEQ() != null) { ps.setString(placeIndicator++, deVO.getConte_IDSEQ()); } if (deVO.getPrefferred_name() != null) { ps.setString(placeIndicator++, deVO.getPrefferred_name()); } if (deVO.getVd_IDSEQ() != null) { ps.setString(placeIndicator++, deVO.getVd_IDSEQ()); } if (deVO.getDec_IDSEQ() != null) { ps.setString(placeIndicator++, deVO.getDec_IDSEQ()); } if (deVO.getPrefferred_def() != null) { ps.setString(placeIndicator++, deVO.getPrefferred_def()); } if (deVO.getAsl_name() != null) { ps.setString(placeIndicator++, deVO.getAsl_name()); } if (deVO.getLong_name() != null) { // allow null update ps.setString(placeIndicator++, deVO.getLong_name()); } if (deVO.getLastest_version_ind() != null) { ps.setString(placeIndicator++, deVO.getLastest_version_ind()); } if (deVO.getBegin_date() != null) { ps.setTimestamp(placeIndicator++, deVO.getBegin_date()); } if (deVO.getEnd_date() != null) { ps.setTimestamp(placeIndicator++, deVO.getEnd_date()); } if (deVO.getChange_note() != null) { // allow null updates ps.setString(placeIndicator++, deVO.getChange_note()); } if (deVO.getOrigin() != null) { ps.setString(placeIndicator++, deVO.getOrigin()); } ps.setString(placeIndicator++, deVO.getDe_IDSEQ()); //statement = conn.createStatement(); int result = ps.executeUpdate(); if (result == 0) { throw new Exception("Unable to Update"); } } catch (Exception e) { logger.error("Error updating Data Element " + deVO.getDe_IDSEQ() + e); errorList.add(DeErrorCodes.API_DE_501); throw new DBException(errorList); } finally { ps = SQLHelper.closePreparedStatement(ps); } }
From source file:com.skilrock.lms.coreEngine.scratchService.inventoryMgmt.common.SalesReturnHelper.java
public String doTransaction(int game_id, int org_id, String orgName, List<PackBean> packlist, List<BookBean> booklist, String rootPath, int userOrgId, int userId, String newBookStatus, Connection conn) throws LMSException { int receipt_id = 0; int transaction_id = 0; double ticket_price = 0, book_price = 0; int nbr_of_tickets_per_book = 0, nbr_of_books_per_pack = 0; double agent_sale_comm_rate = 0; double prizePayOutPer = 0.0; double vat = 0.0; double govtComm = 0.0; double vatAmt = 0.0; double bookTaxableSale = 0.0; double govtCommAmt = 0.0; double commAmt = 0.0; double netAmt = 0.0; double taxableSale = 0.0; double vatBalance = 0.0; long ticketsInScheme = 0; String govtCommRule = null;//from ww w. ja v a 2 s . c o m double fixedAmt = 0.0; double netAmtOrg = 0.0; int DCId = 0; String bookNumber = ""; boolean isBookActivated = true; List<Integer> trnIdList = new ArrayList<Integer>(); try { // get books list from packlist and copy to booklist // new book status on sales return // String newBookStatus = "INACTIVE"; logger.info("***Return Book Status Should be**************" + newBookStatus); if (packlist.size() != 0) { PackBean packbean = null; BookBean bookbean = null; Iterator<PackBean> packListItr = packlist.iterator(); while (packListItr.hasNext()) { packbean = packListItr.next(); String packNbr = packbean.getPackNumber(); String querytoGetBookFrmPack = QueryManager.getST4BookNbrOfPackNbr(); PreparedStatement stmtbookFrmPack = conn.prepareStatement(querytoGetBookFrmPack); stmtbookFrmPack.setString(1, packNbr); ResultSet set = stmtbookFrmPack.executeQuery(); while (set.next()) { String bookNbrfromPack = set.getString("book_nbr"); bookbean = new BookBean(); bookbean.setBookNumber(bookNbrfromPack); bookbean.setValid(true); bookbean.setStatus("Book Is Valid"); booklist.add(bookbean); } } } // Getting Game Details using game id String querytoGameDetail = QueryManager.getST4GameDetailsUsingGameId(); PreparedStatement stmtgamedeatil = conn.prepareStatement(querytoGameDetail); stmtgamedeatil.setInt(1, game_id); ResultSet rsGameDetail = stmtgamedeatil.executeQuery(); while (rsGameDetail.next()) { ticket_price = rsGameDetail.getDouble("ticket_price"); nbr_of_tickets_per_book = rsGameDetail.getInt("nbr_of_tickets_per_book"); nbr_of_books_per_pack = rsGameDetail.getInt("nbr_of_books_per_pack"); agent_sale_comm_rate = rsGameDetail.getDouble("agent_sale_comm_rate"); prizePayOutPer = rsGameDetail.getDouble("prize_payout_ratio"); vat = rsGameDetail.getDouble("vat_amt"); govtComm = rsGameDetail.getDouble("govt_comm_rate"); vatBalance = rsGameDetail.getDouble("vat_balance"); ticketsInScheme = rsGameDetail.getLong("tickets_in_scheme"); govtCommRule = rsGameDetail.getString("govt_comm_type"); fixedAmt = rsGameDetail.getDouble("fixed_amt"); } book_price = ticket_price * nbr_of_tickets_per_book; BookSaleReturnBean bookSaleRetBean; ArrayList<BookSaleReturnBean> bookSaleReturnList = new ArrayList<BookSaleReturnBean>(); String bookNbr, packNbr = null; double commVariance = 0.0; double govtCommRate = 0.0; ResultSet rsCommVar; Iterator iteratorCommVar = booklist.iterator(); while (iteratorCommVar.hasNext()) { bookSaleRetBean = new BookSaleReturnBean(); bookNbr = ((BookBean) iteratorCommVar.next()).getBookNumber(); String commVarianceQuery = "select transacrion_sale_comm_rate,transaction_gov_comm_rate,transaction_date from st_se_game_inv_detail where current_owner=? and current_owner_id=? and game_id=? and book_nbr=? and transaction_at=? order by transaction_date desc limit 1 "; PreparedStatement commVariaceStmt = conn.prepareStatement(commVarianceQuery); commVariaceStmt.setString(1, "AGENT"); commVariaceStmt.setInt(2, org_id); commVariaceStmt.setInt(3, game_id); commVariaceStmt.setString(4, bookNbr); commVariaceStmt.setString(5, "BO"); rsCommVar = commVariaceStmt.executeQuery(); while (rsCommVar.next()) { commVariance = rsCommVar.getDouble("transacrion_sale_comm_rate"); govtCommRate = rsCommVar.getDouble("transaction_gov_comm_rate"); } commAmt = commAmt + book_price * commVariance * 0.01; netAmt = netAmt + book_price * (1 - commVariance * 0.01); govtCommAmt = book_price * govtCommRate * .01; vatAmt = vatAmt + CommonMethods.calculateVat(book_price, commVariance, prizePayOutPer, govtCommRate, vat, govtCommRule, fixedAmt, ticketsInScheme); /* * bookTaxableSale = (((book_price * (100 - (commVariance + * prizePayOutPer + govtCommRate))) / 100) * 100) / (100 + vat); */ // bookTaxableSale=vatAmt/(vat * 0.01); bookTaxableSale = CommonMethods.calTaxableSale(book_price, commVariance, prizePayOutPer, govtCommRate, vat); bookSaleRetBean.setBookNumber(bookNbr); bookSaleRetBean.setBookCommVariance(commVariance); bookSaleRetBean.setDefaultCommVariance(agent_sale_comm_rate); bookSaleRetBean.setTotalSaleComm(commVariance); bookSaleRetBean.setTotalSaleGovtComm(govtCommRate); bookSaleRetBean.setGovtCommAmt(govtCommAmt); bookSaleRetBean.setBookVatAmt(vatAmt); bookSaleRetBean.setBookCommAmt(commAmt); bookSaleRetBean.setBookNetAmt(netAmt); bookSaleRetBean.setBookTaxableSale(bookTaxableSale); bookSaleReturnList.add(bookSaleRetBean); commVariance = 0.0; govtCommRate = 0.0; bookTaxableSale = 0.0; govtCommAmt = 0.0; vatAmt = 0.0; commAmt = 0.0; netAmt = 0.0; } // get comm variance history List<CommVarGovtCommBean> commVariancelist = new ArrayList<CommVarGovtCommBean>(); CommVarGovtCommBean commVarGovtCommBean; String queryCommVarHistory = "select DISTINCT transacrion_sale_comm_rate,transaction_gov_comm_rate from st_se_game_inv_detail where current_owner_id=" + org_id + " and game_id=" + game_id; PreparedStatement stmtCommVarHistory = conn.prepareStatement(queryCommVarHistory); ResultSet rsCommVarHistory = stmtCommVarHistory.executeQuery(); while (rsCommVarHistory.next()) { commVarGovtCommBean = new CommVarGovtCommBean(); commVarGovtCommBean.setCommVariance(rsCommVarHistory.getDouble("transacrion_sale_comm_rate")); commVarGovtCommBean.setGovtComm(rsCommVarHistory.getDouble("transaction_gov_comm_rate")); commVariancelist.add(commVarGovtCommBean); // commVarianceSet.add(rsCommVarHistory.getDouble("transacrion_sale_comm_rate")); } System.out.println(" 22222222222222222222222size for comm var history " + commVariancelist.size() + "pstmt " + stmtCommVarHistory); Iterator iteratorBookSaleReturn; // Iterator iteratorCommVarHistory= commVarianceSet.iterator(); Iterator iteratorCommVarHistory = commVariancelist.iterator(); while (iteratorCommVarHistory.hasNext()) { boolean bookCommVarMatch = false; // logger.info("comm var from history-------------------- // "); Double totCommAmt = 0.0; Double totVatAmt = 0.0; Double totNetAmt = 0.0; Double totTaxableSale = 0.0; Double totGovtComm = 0.0; List bookListforSingleTrn = null; bookListforSingleTrn = new ArrayList<String>(); double commFromHistory = 0.0; double govtCommFromHistory = 0.0; // commFromHistory=(Double)iteratorCommVarHistory.next(); CommVarGovtCommBean commBean = (CommVarGovtCommBean) iteratorCommVarHistory.next(); commFromHistory = commBean.getCommVariance(); govtCommFromHistory = commBean.getGovtComm(); // logger.info("comm var from history-------------------- // "+commFromHistory); iteratorBookSaleReturn = bookSaleReturnList.iterator(); while (iteratorBookSaleReturn.hasNext()) { bookSaleRetBean = (BookSaleReturnBean) iteratorBookSaleReturn.next(); double bookCommVariance = 0.0; double bookGovtCommVariance = 0.0; bookCommVariance = bookSaleRetBean.getTotalSaleComm(); bookGovtCommVariance = bookSaleRetBean.getTotalSaleGovtComm(); // logger.info("commFromHistory " + commFromHistory + // "bookCommVariance " + bookCommVariance); // logger.info("GovtcommFromHistory " + // govtCommFromHistory + "bookGovtCommVariance " + // bookGovtCommVariance); if (commFromHistory == bookCommVariance && govtCommFromHistory == bookGovtCommVariance) { // logger.info("inside boolean isSaleTransactionExist = true; // if%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); if ("YES".equals(Utility.getPropertyValue("IS_SCRATCH_NEW_FLOW_ENABLED"))) { bookNumber = bookSaleRetBean.getBookNumber(); String saleTransactionQuery = "select current_owner_id from st_se_game_inv_status where book_nbr = '" + bookSaleRetBean.getBookNumber() + "' and agent_invoice_id IS NOT NULL"; Statement saleTransactionQueryStmt = conn.createStatement(); ResultSet saleTransactionQueryResultSet = saleTransactionQueryStmt .executeQuery(saleTransactionQuery); if (saleTransactionQueryResultSet.next()) { isSaleTransactionExist = true; } else { isSaleTransactionExist = false; } } if (isSaleTransactionExist) { bookCommVarMatch = true; isBookActivated = false; totCommAmt = totCommAmt + bookSaleRetBean.getBookCommAmt(); totVatAmt = totVatAmt + bookSaleRetBean.getBookVatAmt(); totTaxableSale = totTaxableSale + bookSaleRetBean.getBookTaxableSale(); // logger.info("hello :::::::: " + totTaxableSale // + "history detail " // +bookSaleRetBean.getBookTaxableSale()); totGovtComm = totGovtComm + bookSaleRetBean.getGovtCommAmt(); totNetAmt = totNetAmt + bookSaleRetBean.getBookNetAmt(); bookListforSingleTrn.add(bookSaleRetBean.getBookNumber()); } } } netAmtOrg = netAmtOrg + totNetAmt; if (bookCommVarMatch) { // insert in LMS transaction master String QueryLMSTransMaster = QueryManager.insertInLMSTransactionMaster(); PreparedStatement stmtLMSTransmas = conn.prepareStatement(QueryLMSTransMaster); stmtLMSTransmas.setString(1, "BO"); stmtLMSTransmas.executeUpdate(); // Get Transaction Id From the table. ResultSet rsTransId = stmtLMSTransmas.getGeneratedKeys(); while (rsTransId.next()) { transaction_id = rsTransId.getInt(1); trnIdList.add(transaction_id); } logger.info("transaction_id: " + transaction_id); // 1. Insert Entry in st_lms_bo_transaction_master Table. String queryTranMas = QueryManager.insertInBOTransactionMaster(); PreparedStatement stmtTransmas = conn.prepareStatement(queryTranMas); stmtTransmas.setInt(1, transaction_id); stmtTransmas.setInt(2, userId); stmtTransmas.setInt(3, userOrgId); stmtTransmas.setString(4, "AGENT"); stmtTransmas.setInt(5, org_id); stmtTransmas.setTimestamp(6, new java.sql.Timestamp(new java.util.Date().getTime())); stmtTransmas.setString(7, "SALE_RET"); /* * stmtTransmas.setString(1, "AGENT"); * stmtTransmas.setInt(2, org_id); * stmtTransmas.setTimestamp(3, new java.sql.Timestamp(new * java.util.Date().getTime())); stmtTransmas.setString(4, * "SALE_RET"); */ stmtTransmas.executeUpdate(); // 2. Insert Entry in st_se_bo_agent_transaction table. String queryBoAgtTrans = QueryManager.getST4InsertBoAgentTransaction(); PreparedStatement stmtBoAgtTrans = conn.prepareStatement(queryBoAgtTrans); stmtBoAgtTrans.setInt(1, transaction_id); stmtBoAgtTrans.setInt(2, bookListforSingleTrn.size()); stmtBoAgtTrans.setInt(3, game_id); stmtBoAgtTrans.setInt(4, org_id); stmtBoAgtTrans.setDouble(5, book_price * bookListforSingleTrn.size()); stmtBoAgtTrans.setDouble(6, totCommAmt); stmtBoAgtTrans.setDouble(7, totNetAmt); stmtBoAgtTrans.setString(8, "SALE_RET"); stmtBoAgtTrans.setDouble(9, totVatAmt); stmtBoAgtTrans.setDouble(10, totTaxableSale); stmtBoAgtTrans.setDouble(11, totGovtComm); stmtBoAgtTrans.executeUpdate(); String detHistoryInsQuery = "insert into st_se_game_ticket_inv_history(game_id, book_nbr, " + " current_owner, current_owner_id, date, done_by_oid, done_by_uid, cur_rem_tickets, " + " active_tickets_upto, sold_tickets, status) values (?,?,?,?,?,?,?,?,?,?,?)"; PreparedStatement detHistoryInsPstmt = conn.prepareStatement(detHistoryInsQuery); // fetch game details from game master String fetchGameDetQuery = "select nbr_of_tickets_per_book from st_se_game_master where game_id =" + game_id; Statement fetchGameDetStmt = conn.createStatement(); ResultSet fetchGameDetRs = fetchGameDetStmt.executeQuery(fetchGameDetQuery); int noOfTktPerBooks = -1; if (fetchGameDetRs.next()) { noOfTktPerBooks = fetchGameDetRs.getInt("nbr_of_tickets_per_book"); } // 6. Insert in to st_se_game_inv_detail table. for (int i = 0; i < bookListforSingleTrn.size(); i++) { String bknbr = (String) bookListforSingleTrn.get(i); // logger.info("//Get the pack number of book // number. "); // Get the pack number of book number. String pknbr = null; String queryTogetPackNbr = QueryManager.getST4PackNbrOfBookNbr(); PreparedStatement stm = conn.prepareStatement(queryTogetPackNbr); stm.setString(1, bknbr); ResultSet resultSet = stm.executeQuery(); while (resultSet.next()) { pknbr = resultSet.getString("pack_nbr"); } String queryGameInvDtl = "insert into st_se_game_inv_detail (transaction_id,game_id,pack_nbr, book_nbr,current_owner,current_owner_id,transaction_date,transaction_at,transacrion_sale_comm_rate,transaction_gov_comm_rate,transaction_purchase_comm_rate,warehouse_id,book_status) select ?,?,?,?,?,?,?,?,transacrion_sale_comm_rate,transaction_gov_comm_rate,transaction_purchase_comm_rate,warehouse_id,book_status from st_se_game_inv_detail where book_nbr=? and transaction_at=? order by transaction_date desc limit 1"; PreparedStatement stmtGameInvDtl = conn.prepareStatement(queryGameInvDtl); stmtGameInvDtl.setInt(1, transaction_id); stmtGameInvDtl.setInt(2, game_id); stmtGameInvDtl.setString(3, pknbr); stmtGameInvDtl.setString(4, bknbr); stmtGameInvDtl.setString(5, "BO"); stmtGameInvDtl.setInt(6, userOrgId); stmtGameInvDtl.setTimestamp(7, new java.sql.Timestamp(new java.util.Date().getTime())); stmtGameInvDtl.setString(8, "BO"); stmtGameInvDtl.setString(9, bknbr); stmtGameInvDtl.setString(10, "BO"); stmtGameInvDtl.executeUpdate(); // insert into detail history table Added by arun detHistoryInsPstmt.setInt(1, game_id); detHistoryInsPstmt.setString(2, bknbr); detHistoryInsPstmt.setString(3, "BO"); detHistoryInsPstmt.setInt(4, userOrgId); detHistoryInsPstmt.setTimestamp(5, new java.sql.Timestamp(new java.util.Date().getTime())); detHistoryInsPstmt.setInt(6, userOrgId); detHistoryInsPstmt.setInt(7, userId); detHistoryInsPstmt.setInt(8, noOfTktPerBooks); // logger.info("detHistoryInsPstmt == // "+detHistoryInsPstmt); if ("ACTIVE".equalsIgnoreCase(newBookStatus.trim())) { detHistoryInsPstmt.setInt(9, noOfTktPerBooks); } else { detHistoryInsPstmt.setInt(9, 0); } detHistoryInsPstmt.setInt(10, 0); detHistoryInsPstmt.setString(11, newBookStatus); detHistoryInsPstmt.execute(); // --------------------- } } if (isBookActivated) { String bknbr = bookNumber; // System.out.println("//Get the pack number of book // number. "); // Get the pack number of book number. String pknbr = null; String queryTogetPackNbr = QueryManager.getST4PackNbrOfBookNbr(); PreparedStatement stm = conn.prepareStatement(queryTogetPackNbr); stm.setString(1, bknbr); ResultSet resultSet = stm.executeQuery(); while (resultSet.next()) { pknbr = resultSet.getString("pack_nbr"); } String queryGameInvDtl = "insert into st_se_game_inv_detail (transaction_id,game_id,pack_nbr, book_nbr,current_owner,current_owner_id,transaction_date,transaction_at,transacrion_sale_comm_rate,transaction_gov_comm_rate,transaction_purchase_comm_rate,warehouse_id,book_status) select ?,?,?,?,?,?,?,?,transacrion_sale_comm_rate,transaction_gov_comm_rate,transaction_purchase_comm_rate,warehouse_id,book_status from st_se_game_inv_detail where book_nbr=? and transaction_at=? order by transaction_date desc limit 1"; PreparedStatement stmtGameInvDtl = conn.prepareStatement(queryGameInvDtl); stmtGameInvDtl.setInt(1, transaction_id); stmtGameInvDtl.setInt(2, game_id); stmtGameInvDtl.setString(3, pknbr); stmtGameInvDtl.setString(4, bknbr); stmtGameInvDtl.setString(5, "BO"); stmtGameInvDtl.setInt(6, userOrgId); stmtGameInvDtl.setTimestamp(7, new java.sql.Timestamp(new java.util.Date().getTime())); stmtGameInvDtl.setString(8, "BO"); stmtGameInvDtl.setString(9, bknbr); stmtGameInvDtl.setString(10, "BO"); stmtGameInvDtl.executeUpdate(); } } logger.info("5. Update st_se_game_inv_status Table. "); // 5. Update st_se_game_inv_status Table. for (int i = 0; i < bookSaleReturnList.size(); i++) { String bknbr = ((BookSaleReturnBean) bookSaleReturnList.get(i)).getBookNumber(); String queryGameInvStatus = QueryManager.getST4UdateGameInvStatusForBook(); PreparedStatement stmtGameInvStatus = conn.prepareStatement(queryGameInvStatus); stmtGameInvStatus.setString(1, newBookStatus); stmtGameInvStatus.setInt(2, userOrgId); stmtGameInvStatus.setString(3, null); stmtGameInvStatus.setInt(4, game_id); stmtGameInvStatus.setString(5, bknbr); stmtGameInvStatus.executeUpdate(); } // get auto generated treciept number Statement autoGenRecptPstmtBOCRNote = null; // String getLatestRecieptNumberBO="SELECT * from // st_bo_receipt_gen_mapping where receipt_type=? ORDER BY // generated_id DESC LIMIT 1 "; String queryRcpt = "SELECT * from st_lms_bo_receipts where receipt_type like ('CR_NOTE%') ORDER BY generated_id DESC LIMIT 1"; autoGenRecptPstmtBOCRNote = conn.createStatement(); // autoGenRecptPstmtBO.setString(1, "CR_NOTE"); logger.info("queryRcpt--" + queryRcpt); ResultSet recieptRsBO = autoGenRecptPstmtBOCRNote.executeQuery(queryRcpt); String lastRecieptNoGeneratedBO = null; while (recieptRsBO.next()) { lastRecieptNoGeneratedBO = recieptRsBO.getString("generated_id"); } String autoGeneRecieptNoBO = GenerateRecieptNo.getRecieptNo("CR_NOTE", lastRecieptNoGeneratedBO, "BO"); // get auto generated delivery Challan number // String getLatestDSRCNumber="SELECT * from // st_bo_receipt_gen_mapping where receipt_type=? ORDER BY // generated_id DESC LIMIT 1 "; // autoGenRecptPstmtBO=conn.prepareStatement(getLatestDSRCNumber); PreparedStatement autoGenRecptPstmtBO = null; autoGenRecptPstmtBO = conn.prepareStatement(QueryManager.getBOLatestReceiptNb()); autoGenRecptPstmtBO.setString(1, "DSRCHALLAN"); ResultSet DCRs = autoGenRecptPstmtBO.executeQuery(); String lastDSRCNoGenerated = null; while (DCRs.next()) { lastDSRCNoGenerated = DCRs.getString("generated_id"); } String autoGeneDCNo = null; autoGeneDCNo = GenerateRecieptNo.getRecieptNo("DSRCHALLAN", lastDSRCNoGenerated, "BO"); // insert into receipts master PreparedStatement stmtRecptId = conn.prepareStatement(QueryManager.insertInReceiptMaster()); stmtRecptId.setString(1, "BO"); stmtRecptId.executeUpdate(); ResultSet rsRecptId = stmtRecptId.getGeneratedKeys(); while (rsRecptId.next()) { receipt_id = rsRecptId.getInt(1); } // Insert Entry in st_bo_receipt table. // String queryRecptId=QueryManager.getST4InsertBoReceipts(); stmtRecptId = conn.prepareStatement(QueryManager.insertInBOReceipts()); stmtRecptId.setInt(1, receipt_id); stmtRecptId.setString(2, "CR_NOTE"); stmtRecptId.setInt(3, org_id); stmtRecptId.setString(4, "AGENT"); stmtRecptId.setString(5, autoGeneRecieptNoBO); stmtRecptId.setTimestamp(6, Util.getCurrentTimeStamp()); /* * stmtRecptId.setString(1, "CR_NOTE"); stmtRecptId.setInt(2, * org_id); */ stmtRecptId.executeUpdate(); // insert reciept id for delivery challan stmtRecptId = conn.prepareStatement(QueryManager.insertInReceiptMaster()); stmtRecptId.setString(1, "BO"); stmtRecptId.executeUpdate(); ResultSet rsDC = stmtRecptId.getGeneratedKeys(); while (rsDC.next()) { DCId = rsDC.getInt(1); } stmtRecptId = conn.prepareStatement(QueryManager.insertInBOReceipts()); stmtRecptId.setInt(1, DCId); stmtRecptId.setString(2, "DSRCHALLAN"); stmtRecptId.setInt(3, org_id); stmtRecptId.setString(4, "AGENT"); stmtRecptId.setString(5, autoGeneDCNo); stmtRecptId.setTimestamp(6, Util.getCurrentTimeStamp()); stmtRecptId.execute(); // 4. Insert Entry in st_lms_bo_receipts_trn_mapping table. PreparedStatement stmtRcptTrnMapping = conn.prepareStatement(QueryManager.insertBOReceiptTrnMapping()); for (int i = 0; i < trnIdList.size(); i++) { stmtRcptTrnMapping.setInt(1, receipt_id); stmtRcptTrnMapping.setInt(2, (Integer) trnIdList.get(i)); stmtRcptTrnMapping.executeUpdate(); } // 4. Insert Entry in st_lms_bo_receipts_trn_mapping table for // delivery // challan for (int i = 0; i < trnIdList.size(); i++) { stmtRcptTrnMapping.setInt(1, DCId); stmtRcptTrnMapping.setInt(2, (Integer) trnIdList.get(i)); stmtRcptTrnMapping.executeUpdate(); } // insert into invoice and delivery challan mapping table String insertCRNoteDCMapping = "insert into st_se_bo_invoice_delchallan_mapping(id,generated_invoice_id,generated_del_challan_id) values(?,?,?)"; PreparedStatement boCRNoteDCMappingStmt = conn.prepareStatement(insertCRNoteDCMapping); boCRNoteDCMappingStmt.setInt(1, receipt_id); boCRNoteDCMappingStmt.setString(2, autoGeneRecieptNoBO); boCRNoteDCMappingStmt.setString(3, autoGeneDCNo); boCRNoteDCMappingStmt.executeUpdate(); boolean isValid = OrgCreditUpdation.updateOrganizationBalWithValidate(netAmtOrg, "TRANSACTION", "SALE_RET", org_id, 0, "AGENT", 0, conn); if (!isValid) throw new LMSException(); /*boolean isUpdateDone = OrgCreditUpdation.updateCreditLimitForAgent( org_id, "SALE_RET", netAmtOrg, conn);*/ // session.setAttribute("DEL_CHALLAN_ID", DCId); // if (receipt_id > 0) { // GraphReportHelper graphReportHelper = new GraphReportHelper(); // graphReportHelper.createTextReportBO(receipt_id, orgName, // userOrgId, rootPath); // } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new LMSException(e); } return String.valueOf(DCId) + "Nxt" + String.valueOf(receipt_id); }
From source file:dk.netarkivet.harvester.datamodel.DomainDBDAO.java
/** * Insert new harvest info for a domain. * @param c //from ww w .j a va 2 s . com * A connection to the database * @param d * A domain to insert on. The domains ID must be correct. * @param harvestInfo * Harvest info to insert. */ private void insertHarvestInfo(Connection c, Domain d, HarvestInfo harvestInfo) { PreparedStatement s = null; try { // Note that the config_id is grabbed from the configurations table. s = c.prepareStatement( "INSERT INTO historyinfo " + "( stopreason, objectcount, bytecount, config_id, " + "job_id, harvest_id, harvest_time ) " + "VALUES ( ?, ?, ?, ?, ?, ?, ? )", Statement.RETURN_GENERATED_KEYS); s.setInt(1, harvestInfo.getStopReason().ordinal()); s.setLong(2, harvestInfo.getCountObjectRetrieved()); s.setLong(3, harvestInfo.getSizeDataRetrieved()); // TODO More stable way to get IDs, use a select s.setLong(4, d.getConfiguration(harvestInfo.getDomainConfigurationName()).getID()); if (harvestInfo.getJobID() != null) { s.setLong(5, harvestInfo.getJobID()); } else { s.setNull(5, Types.BIGINT); } s.setLong(6, harvestInfo.getHarvestID()); s.setTimestamp(7, new Timestamp(harvestInfo.getDate().getTime())); s.executeUpdate(); harvestInfo.setID(DBUtils.getGeneratedID(s)); } catch (SQLException e) { throw new IOFailure("SQL error while inserting harvest info " + harvestInfo + " for " + d + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } }
From source file:com.alfaariss.oa.engine.session.jdbc.JDBCSessionFactory.java
/** * Persist the session in the JDBC storage. * /*from ww w. j a va2 s . c o m*/ * The sessionstate is saved with its name. * @param session The session to persist. * @throws PersistenceException If persistance fails. * @see IEntityManager#persist(IEntity) */ public void persist(JDBCSession session) throws PersistenceException { if (session == null) throw new IllegalArgumentException("Suplied session is empty or invalid"); Connection oConnection = null; PreparedStatement psInsert = null; PreparedStatement psDelete = null; PreparedStatement psUpdate = null; String id = session.getId(); try { oConnection = _oDataSource.getConnection(); if (id == null) // New Session { try { byte[] baId = new byte[ISession.ID_BYTE_LENGTH]; do { _random.nextBytes(baId); try { id = ModifiedBase64.encode(baId); } catch (UnsupportedEncodingException e) { _logger.error("Could not create id for byte[]: " + baId, e); throw new PersistenceException(SystemErrors.ERROR_INTERNAL); } } while (exists(id)); //Key allready exists // Update expiration time and id long expiration = System.currentTimeMillis() + _lExpiration; session.setTgtExpTime(expiration); session.setId(id); //Create statement psInsert = oConnection.prepareStatement(_sInsertQuery); psInsert.setString(1, id); psInsert.setString(2, session.getTGTId()); psInsert.setInt(3, session.getState().ordinal()); psInsert.setString(4, session.getRequestorId()); psInsert.setString(5, session.getProfileURL()); psInsert.setBytes(6, Serialize.encode(session.getUser())); psInsert.setTimestamp(7, new Timestamp(expiration)); psInsert.setBoolean(8, session.isForcedAuthentication()); psInsert.setBoolean(9, session.isPassive()); psInsert.setBytes(10, Serialize.encode(session.getAttributes())); psInsert.setString(11, session.getForcedUserID()); psInsert.setBytes(12, Serialize.encode(session.getLocale())); psInsert.setBytes(13, Serialize.encode(session.getSelectedAuthNProfile())); psInsert.setBytes(14, Serialize.encode(session.getAuthNProfiles())); int i = psInsert.executeUpdate(); _logger.info(i + " new session(s) added: " + id + " for requestor '" + session.getRequestorId() + "'"); } catch (SQLException e) { _logger.error("Could not execute insert query: " + _sInsertQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_INSERT); } } else if (session.isExpired()) // Expired { try { _logger.info("Session Expired: " + id); _eventLogger.info(new UserEventLogItem(session, null, UserEvent.SESSION_EXPIRED, this, null)); psDelete = oConnection.prepareStatement(_sRemoveQuery); psDelete.setString(1, id); int i = psDelete.executeUpdate(); _logger.debug(i + " session(s) removed: " + id); } catch (SQLException e) { _logger.error("Could not execute delete query: " + _sRemoveQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_REMOVE); } } else // Update { try { // Update expiration time long expiration = System.currentTimeMillis() + _lExpiration; session.setExpTime(expiration); psUpdate = oConnection.prepareStatement(_sUpdateQuery); psUpdate.setString(1, session.getTGTId()); psUpdate.setInt(2, session.getState().ordinal()); psUpdate.setString(3, session.getRequestorId()); psUpdate.setString(4, session.getProfileURL()); psUpdate.setBytes(5, Serialize.encode(session.getUser())); psUpdate.setTimestamp(6, new Timestamp(expiration)); psUpdate.setBoolean(7, session.isForcedAuthentication()); psUpdate.setBoolean(8, session.isPassive()); psUpdate.setBytes(9, Serialize.encode(session.getAttributes())); psUpdate.setString(10, session.getForcedUserID()); psUpdate.setBytes(11, Serialize.encode(session.getLocale())); psUpdate.setBytes(12, Serialize.encode(session.getSelectedAuthNProfile())); psUpdate.setBytes(13, Serialize.encode(session.getAuthNProfiles())); psUpdate.setString(14, id); int i = psUpdate.executeUpdate(); _logger.info( i + " session(s) updated: " + id + " for requestor '" + session.getRequestorId() + "'"); } catch (SQLException e) { _logger.error("Could not execute update query: " + _sUpdateQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_UPDATE); } } } catch (PersistenceException e) { throw e; } catch (Exception e) { _logger.error("Internal error during persist of session with id: " + id, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_UPDATE); } finally { try { if (psInsert != null) psInsert.close(); } catch (SQLException e) { _logger.debug("Could not close insert statement", e); } try { if (psDelete != null) psDelete.close(); } catch (SQLException e) { _logger.debug("Could not close delete statement", e); } try { if (psUpdate != null) psUpdate.close(); } catch (SQLException e) { _logger.debug("Could not close update statement", e); } try { if (oConnection != null) oConnection.close(); } catch (SQLException e) { _logger.debug("Could not close connection", e); } } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insert(final Pand pand) throws DAOException { try {/*from www.j ava 2 s. c o m*/ jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("insert into bag_pand (" + "bag_pand_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "pand_geometrie," + "bouwjaar," + "pand_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)"); ps.setLong(1, pand.getIdentificatie()); ps.setInt(2, pand.getAanduidingRecordInactief().ordinal()); ps.setLong(3, pand.getAanduidingRecordCorrectie()); ps.setInt(4, pand.getOfficieel().ordinal()); ps.setString(5, pand.getPandGeometrie()); ps.setInt(6, pand.getBouwjaar()); ps.setString(7, pand.getPandStatus()); ps.setTimestamp(8, new Timestamp(pand.getBegindatumTijdvakGeldigheid().getTime())); if (pand.getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(pand.getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, pand.getInOnderzoek().ordinal()); ps.setDate(11, new Date(pand.getDocumentdatum().getTime())); ps.setString(12, pand.getDocumentnummer()); return ps; } }); } catch (DataAccessException e) { throw new DAOException("Error inserting pand: " + pand.getIdentificatie(), e); } }
From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java
private EventObmId markUpdated(Connection con, EventObmId eventObmId) throws SQLException { PreparedStatement st = null; try {/*w w w . j a va 2 s . c o m*/ st = con.prepareStatement("UPDATE Event SET event_timeupdate=? WHERE event_id=?"); st.setTimestamp(1, new Timestamp(obmHelper.selectNow(con).getTime())); st.setInt(2, eventObmId.getObmId()); st.execute(); } finally { obmHelper.cleanup(null, st, null); } return eventObmId; }
From source file:nl.nn.adapterframework.statistics.jdbc.StatisticsKeeperStore.java
public Object start(Date now, Date mainMark, Date detailMark) throws SenderException { List nameList = new LinkedList(); List valueList = new LinkedList(); now = new Date(); SessionInfo sessionInfo = new SessionInfo(); PreparedStatement stmt = null; long freeMem = Runtime.getRuntime().freeMemory(); long totalMem = Runtime.getRuntime().totalMemory(); addPeriodIndicator(nameList, valueList, now, new String[][] { PERIOD_FORMAT_HOUR, PERIOD_FORMAT_DATEHOUR }, PERIOD_ALLOWED_LENGTH_HOUR, "s", mainMark); addPeriodIndicator(nameList, valueList, now, new String[][] { PERIOD_FORMAT_DAY, PERIOD_FORMAT_DATE, PERIOD_FORMAT_WEEKDAY }, PERIOD_ALLOWED_LENGTH_DAY, "s", mainMark); addPeriodIndicator(nameList, valueList, now, new String[][] { PERIOD_FORMAT_WEEK, PERIOD_FORMAT_YEARWEEK }, PERIOD_ALLOWED_LENGTH_WEEK, "s", mainMark); addPeriodIndicator(nameList, valueList, now, new String[][] { PERIOD_FORMAT_MONTH, PERIOD_FORMAT_YEARMONTH }, PERIOD_ALLOWED_LENGTH_MONTH, "s", mainMark);/* www . j a va 2s . com*/ addPeriodIndicator(nameList, valueList, now, new String[][] { PERIOD_FORMAT_YEAR }, PERIOD_ALLOWED_LENGTH_YEAR, "s", mainMark); try { Connection connection = getConnection(); sessionInfo.connection = connection; String hostname = Misc.getHostname(); int hostKey = hosts.findOrInsert(connection, hostname); sessionInfo.eventKey = JdbcUtil.executeIntQuery(connection, selectNextValueQuery); String insertEventQuery = null; try { String insertClause = insertEventQueryInsertClause; String valuesClause = insertEventQueryValuesClause; for (Iterator it = nameList.iterator(); it.hasNext();) { String name = (String) it.next(); insertClause += "," + name; valuesClause += ",?"; } insertEventQuery = insertClause + valuesClause + ")"; if (trace && log.isDebugEnabled()) log.debug("prepare and execute query [" + insertEventQuery + "]"); stmt = connection.prepareStatement(insertEventQuery); int pos = 1; stmt.setInt(pos++, sessionInfo.eventKey); stmt.setInt(pos++, instanceKey); stmt.setInt(pos++, hostKey); stmt.setLong(pos++, totalMem - freeMem); stmt.setLong(pos++, totalMem); stmt.setTimestamp(pos++, new Timestamp(now.getTime())); stmt.setTimestamp(pos++, new Timestamp(mainMark.getTime())); for (Iterator it = valueList.iterator(); it.hasNext();) { String value = (String) it.next(); stmt.setString(pos++, value); } stmt.execute(); } catch (Exception e) { throw new JdbcException("could not execute query [" + insertEventQuery + "]", e); } finally { if (stmt != null) { try { stmt.close(); } catch (Exception e) { throw new JdbcException("could not close statement for query [" + insertEventQuery + "]", e); } } } return sessionInfo; } catch (Exception e) { throw new SenderException(e); } }
From source file:com.uas.document.DocumentDAO.java
@Override public DocumentDTO createDocument(DocumentDTO dDto) { PreparedStatement preparedStmt = null; Connection c = null;/*w w w . j a va 2 s. c o m*/ ResultSet rs = null; // try { c = DataSourceSingleton.getInstance().getConnection(); String SQL = "INSERT INTO \"public\".\"document\" (\"id\",\"fileName\",\"fileDate\",\"idArea\",\"isFolder\") VALUES (?,?,?,?,?)"; preparedStmt = c.prepareStatement(SQL); preparedStmt.setInt(1, dDto.getId()); //System.out.println(""); preparedStmt.setString(2, dDto.getFilename()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); ////System.out.println("Dto.getFileDate().substring(0,10): " + dDto.getFileDate().substring(0,10)); java.util.Date parsedDate = dateFormat.parse(dDto.getFileDate().substring(0, 10)); Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime()); preparedStmt.setTimestamp(3, timestamp); preparedStmt.setInt(4, dDto.getIdArea()); preparedStmt.setBoolean(5, dDto.getIsFolder()); preparedStmt.executeUpdate(); TransactionRecordFacade tFac = new TransactionRecordFacade(); TransactionRecordDTO tDto = new TransactionRecordDTO(); tDto.getObjectDTO().setId(dDto.getId()); tDto.getTransactionTypeDTO().setId(3); tDto.getUsuarioDTO().setId(dDto.getCreatedBy()); tFac.createTransactionRecord(tDto); } catch (Exception e) { e.printStackTrace(); } finally { try { if (c != null) { c.close(); } if (rs != null) { rs.close(); } if (preparedStmt != null) { preparedStmt.close(); } } catch (Exception e) { e.printStackTrace(); } } return dDto; }