List of usage examples for java.math BigDecimal add
public BigDecimal add(BigDecimal augend)
From source file:com.hengyi.japp.print.client.controller.MdController.java
@FXML private void handleAutoXd() { try {//from w w w . j a v a2 s.c om MdValidate.checkMdInput(md); md.xdsProperty().clear(); md.setXds(FXCollections.observableArrayList(IntStream.range(0, md.getZcanmge()).mapToObj(i -> { Xd xd = new Xd(); xd.zboxsnrProperty().set(i + 1); xd.sapYmmmachProperty().bind(md.sapYmmmachProperty()); xd.zrolmgeProperty().bind(md.zrolmgeProperty()); return xd; }).collect(Collectors.toList()))); if (md.getZdzflg()) { zsgwghtColumn.setEditable(false); md.getXds().forEach(xd -> { xd.zsnwghtProperty().bind(md.zcnwghtProperty()); xd.zsgwghtProperty().bind(new ObjectBinding<BigDecimal>() { { bind(xd.zsnwghtProperty(), xd.zrolmgeProperty(), md.sapYmmzhixProperty(), md.sapYmmtonggProperty()); } @Override protected BigDecimal computeValue() { return xd.getZsnwght().add(tareF.apply(md, xd)); } }); }); } else { zsgwghtColumn.setEditable(true); md.getXds().forEach(xd -> { xd.zsnwghtProperty().bind(new ObjectBinding<BigDecimal>() { { bind(xd.zsgwghtProperty(), xd.zrolmgeProperty(), md.sapYmmzhixProperty(), md.sapYmmtonggProperty()); } @Override protected BigDecimal computeValue() { return xd.getZsgwght().add(tareF.apply(md, xd).negate()); } }); }); } md.zsgwghtProperty().bind(new ObjectBinding<BigDecimal>() { { md.getXds().forEach(xd -> bind(xd.zsgwghtProperty())); } @Override protected BigDecimal computeValue() { BigDecimal result = BigDecimal.ZERO; for (Xd xd : md.getXds()) { result = result.add(xd.getZsgwght()); } return result; } }); md.zsnwghtProperty().bind(new ObjectBinding<BigDecimal>() { { md.getXds().forEach(xd -> bind(xd.zsnwghtProperty())); } @Override protected BigDecimal computeValue() { BigDecimal result = BigDecimal.ZERO; for (Xd xd : md.getXds()) { result = result.add(xd.getZsnwght()); } return result; } }); } catch (AppException e) { Util.alertDialog(e); } }
From source file:co.nubetech.hiho.mapreduce.lib.db.apache.TextSplitter.java
/** * Return a BigDecimal representation of string 'str' suitable for use * in a numerically-sorting order.//w ww.j a v a 2s . c o m */ BigDecimal stringToBigDecimal(String str) { BigDecimal result = BigDecimal.ZERO; BigDecimal curPlace = ONE_PLACE; // start with 1/65536 to compute the first digit. int len = Math.min(str.length(), MAX_CHARS); for (int i = 0; i < len; i++) { int codePoint = str.codePointAt(i); result = result.add(tryDivide(new BigDecimal(codePoint), curPlace)); // advance to the next less significant place. e.g., 1/(65536^2) for the second char. curPlace = curPlace.multiply(ONE_PLACE); } return result; }
From source file:com.ar.dev.tierra.api.controller.DetalleFacturaController.java
@RequestMapping(value = "/add", method = RequestMethod.POST) public ResponseEntity<?> add(OAuth2Authentication authentication, @RequestParam("idFactura") int idFactura, @RequestParam("idProducto") int idProducto, @RequestParam("idItem") int idItem, @RequestParam("cantidadItem") int cantidadItem) { /*Instancia de nuevo detalle*/ DetalleFactura detalleFactura = new DetalleFactura(); /*Traemos los objectos necesarios para aadir el detalle*/ Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName()); Producto prod = facadeService.getProductoDAO().findById(idProducto); WrapperStock stock = facadeService.getStockDAO().searchStockById(idItem, user.getUsuarioSucursal().getIdSucursal()); Factura factura = facadeService.getFacturaDAO().searchById(idFactura); /*Bandera de control*/ boolean control = false; /*Variable de calculo de cantidad*/ @SuppressWarnings("UnusedAssignment") int cantidadStock = 0; detalleFactura.setUsuarioCreacion(user.getIdUsuario()); detalleFactura.setFechaCreacion(new Date()); detalleFactura.setEstadoDetalle(true); if (prod.getCantidadTotal() >= cantidadItem) { if (stock.getStockTierra() != null) { if (stock.getStockTierra().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockTierra().getCantidad() - cantidadItem; stock.getStockTierra().setCantidad(cantidadStock); control = true;/*from www .ja v a2 s . c o m*/ } } if (stock.getStockBebelandia() != null) { if (stock.getStockBebelandia().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockBebelandia().getCantidad() - cantidadItem; stock.getStockBebelandia().setCantidad(cantidadStock); control = true; } } if (stock.getStockLibertador() != null) { if (stock.getStockLibertador().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockLibertador().getCantidad() - cantidadItem; stock.getStockLibertador().setCantidad(cantidadStock); control = true; } } if (control) { int cantidadTotal = prod.getCantidadTotal(); /*seteamos cantidad nueva de productos*/ prod.setCantidadTotal(cantidadTotal - cantidadItem); /*seteamos producto en el detalle*/ detalleFactura.setProducto(prod); /*Calculamos el total del detalle*/ BigDecimal monto = detalleFactura.getProducto().getPrecioVenta() .multiply(BigDecimal.valueOf(cantidadItem)); /*seteamos el total del detalle*/ detalleFactura.setTotalDetalle(monto); /*seteamos la factura del detalle*/ detalleFactura.setFactura(factura); /*seteamos descuento en cero*/ detalleFactura.setDescuentoDetalle(BigDecimal.ZERO); /*seteamos la cantidad de items en el detalle*/ detalleFactura.setCantidadDetalle(cantidadItem); /*Indicamos el idStock del detalle*/ detalleFactura.setIdStock(idItem); /*Actualizamos producto*/ facadeService.getProductoDAO().update(prod); /*Actualizamos el stock*/ facadeService.getStockDAO().update(stock); /*Insertamos el nuevo detalle*/ facadeService.getDetalleFacturaDAO().add(detalleFactura); /*Traemos lista de detalles, calculamos su nuevo total y actualizamos*/ List<DetalleFactura> detallesFactura = facadeService.getDetalleFacturaDAO() .facturaDetalle(idFactura); BigDecimal sumMonto = new BigDecimal(BigInteger.ZERO); for (DetalleFactura detailList : detallesFactura) { sumMonto = sumMonto.add(detailList.getTotalDetalle()); } factura.setTotal(sumMonto); factura.setFechaModificacion(new Date()); factura.setUsuarioModificacion(user.getIdUsuario()); facadeService.getFacturaDAO().update(factura); JsonResponse msg = new JsonResponse("Success", "Detalle agregado con exito"); return new ResponseEntity<>(msg, HttpStatus.OK); } else { JsonResponse msg = new JsonResponse("Error", "Stock insuficiente."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } } else { JsonResponse msg = new JsonResponse("Error", "Stock insuficiente."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } }
From source file:churashima.action.manage.ExpensesAction.java
@Execute(validator = false) public String search() { String strSerachPlace = null; if (StringUtils.isNotEmpty(expensesForm.searchPlace)) { strSerachPlace = "%" + expensesForm.searchPlace + "%"; }/*w ww . j a va 2s .c o m*/ String strSerachName = null; if (StringUtils.isNotEmpty(expensesForm.searchName)) { strSerachName = "%" + expensesForm.searchName + "%"; } Long longSubjectId = null; if (expensesForm.searchSubjectId != null && !"all".equals(expensesForm.searchSubjectId)) { longSubjectId = Long.valueOf(expensesForm.searchSubjectId); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date dateFrom = null; if (StringUtils.isNotEmpty(expensesForm.searchDayFrom)) { try { dateFrom = sdf.parse(expensesForm.searchDayFrom); } catch (ParseException e) { e.printStackTrace(); } } Date dateTo = null; if (StringUtils.isNotEmpty(expensesForm.searchDayTo)) { try { dateTo = sdf.parse(expensesForm.searchDayTo); } catch (ParseException e) { e.printStackTrace(); } } ExpensesDao expensesDao = SingletonS2Container.getComponent(ExpensesDao.class); List<Expenses> expensesList = expensesDao.selectForSearch(null, longSubjectId, strSerachPlace, strSerachName, dateFrom, dateTo, expensesForm.searchPrice, null, null); SubjectDao subjectDao = SingletonS2Container.getComponent(SubjectDao.class); expensesForm.subjectList = subjectDao.selectForSearch(null, null); expensesForm.expensesList = expensesList; // ?? BigDecimal sumPriceTotal = BigDecimal.valueOf(0); for (Expenses expenses : expensesList) { sumPriceTotal = sumPriceTotal.add(expenses.price); } expensesForm.sumPriceTotal = sumPriceTotal; return "expensesList.jsp"; }
From source file:com.salesmanager.core.util.ProductUtil.java
/** * Format like <blue>[if discount striked]SYMBOL BASEAMOUNT</blue> [if * discount <red>SYMBOL DISCOUNTAMOUNT</red>] [if discount <red>Save: * PERCENTAGE AMOUNT</red>] [if qty discount <red>Buy QTY save [if price qty * discount AMOUNT] [if percent qty discount PERCENT]</red>] * //from w w w .j a v a 2s. c om * @param ctx * @param view * @return */ public static String formatHTMLProductPriceWithAttributes(Locale locale, String currency, Product view, Collection attributes, boolean showDiscountDate) { if (currency == null) { log.error("Currency is null ..."); return "-N/A-"; } int decimalPlace = 2; String prefix = ""; String suffix = ""; Map currenciesmap = RefCache.getCurrenciesListWithCodes(); Currency c = (Currency) currenciesmap.get(currency); // regular price BigDecimal bdprodprice = view.getProductPrice(); // determine any properties prices BigDecimal attributesPrice = null; if (attributes != null) { Iterator i = attributes.iterator(); while (i.hasNext()) { ProductAttribute attr = (ProductAttribute) i.next(); if (!attr.isAttributeDisplayOnly() && attr.getOptionValuePrice().longValue() > 0) { if (attributesPrice == null) { attributesPrice = new BigDecimal(0); } attributesPrice = attributesPrice.add(attr.getOptionValuePrice()); } } } if (attributesPrice != null) { bdprodprice = bdprodprice.add(attributesPrice);// new price with // properties } // discount price java.util.Date spdate = null; java.util.Date spenddate = null; BigDecimal bddiscountprice = null; Special special = view.getSpecial(); if (special != null) { bddiscountprice = special.getSpecialNewProductPrice(); if (attributesPrice != null) { bddiscountprice = bddiscountprice.add(attributesPrice);// new // price // with // properties } spdate = special.getSpecialDateAvailable(); spenddate = special.getExpiresDate(); } // all other prices Set prices = view.getPrices(); if (prices != null) { Iterator pit = prices.iterator(); while (pit.hasNext()) { ProductPrice pprice = (ProductPrice) pit.next(); if (pprice.isDefaultPrice()) { pprice.setLocale(locale); suffix = pprice.getPriceSuffix(); bddiscountprice = null; spdate = null; spenddate = null; bdprodprice = pprice.getProductPriceAmount(); if (attributesPrice != null) { bdprodprice = bdprodprice.add(attributesPrice);// new // price // with // properties } ProductPriceSpecial ppspecial = pprice.getSpecial(); if (ppspecial != null) { if (ppspecial.getProductPriceSpecialStartDate() != null && ppspecial.getProductPriceSpecialEndDate() != null) { spdate = ppspecial.getProductPriceSpecialStartDate(); spenddate = ppspecial.getProductPriceSpecialEndDate(); } bddiscountprice = ppspecial.getProductPriceSpecialAmount(); if (bddiscountprice != null && attributesPrice != null) { bddiscountprice = bddiscountprice.add(attributesPrice);// new price with // properties } } break; } } } double fprodprice = 0; ; if (bdprodprice != null) { fprodprice = bdprodprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); } // regular price String String regularprice = CurrencyUtil.displayFormatedCssAmountWithCurrency(bdprodprice, currency); Date dt = new Date(); // discount price String String discountprice = null; String savediscount = null; if (bddiscountprice != null && (spdate != null && spdate.before(new Date(dt.getTime())) && spenddate.after(new Date(dt.getTime())))) { double fdiscountprice = bddiscountprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); discountprice = CurrencyUtil.displayFormatedAmountWithCurrency(bddiscountprice, currency); double arith = fdiscountprice / fprodprice; double fsdiscount = 100 - arith * 100; Float percentagediscount = new Float(fsdiscount); savediscount = String.valueOf(percentagediscount.intValue()); } StringBuffer p = new StringBuffer(); p.append("<div class='product-price'>"); if (discountprice == null) { p.append("<div class='product-price-price' style='width:50%;float:left;'>"); p.append(regularprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</div>"); p.append("<div class='product-line'> </div>"); } else { p.append("<div style='width:50%;float:left;'>"); p.append("<strike>").append(regularprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</strike>"); p.append("</div>"); p.append("<div style='width:50%;float:right;'>"); p.append("<font color='red'>").append(discountprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</font>").append("<br>").append("<font color='red' style='font-size:75%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.save")).append(": ") .append(savediscount) .append(LabelUtil.getInstance().getText(locale, "label.generic.percentsign")).append(" ") .append(LabelUtil.getInstance().getText(locale, "label.generic.off")).append("</font>"); if (showDiscountDate && spenddate != null) { p.append("<br>").append(" <font style='font-size:65%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.until")).append(" ") .append(DateUtil.formatDate(spenddate)).append("</font>"); } p.append("</div>").toString(); } p.append("</div>"); return p.toString(); }
From source file:com.webbfontaine.valuewebb.search.custom.UserCriterion.java
private Criterion getPercentRange() { BigDecimal bdValue = new BigDecimal(value.toString()); BigDecimal range = bdValue.multiply(new BigDecimal(diff).divide(new BigDecimal(100))); BigDecimal bdValueFrom = bdValue.subtract(range); BigDecimal bdValueTo = bdValue.add(range); return Restrictions.and(Restrictions.ge(fullKey, bdValueFrom), Restrictions.le(fullKey, bdValueTo)); }
From source file:co.nubetech.apache.hadoop.TextSplitter.java
/** * Return a BigDecimal representation of string 'str' suitable for use in a * numerically-sorting order./*from w w w. jav a 2 s.co m*/ */ BigDecimal stringToBigDecimal(String str) { BigDecimal result = BigDecimal.ZERO; BigDecimal curPlace = ONE_PLACE; // start with 1/65536 to compute the // first digit. int len = Math.min(str.length(), MAX_CHARS); for (int i = 0; i < len; i++) { int codePoint = str.codePointAt(i); result = result.add(tryDivide(new BigDecimal(codePoint), curPlace)); // advance to the next less significant place. e.g., 1/(65536^2) for // the second char. curPlace = curPlace.multiply(ONE_PLACE); } return result; }
From source file:com.redhat.rhtracking.core.services.InvoiceServiceHandler.java
@Override public Map<String, Object> saveInvoice(Map<String, Object> event) { logger.debug("ssssssssss " + event); Map<String, Object> response = new HashMap<>(); int totalHours = (int) event.get("platformQuantity") + (int) event.get("middlewareQuantity") + (int) event.get("workshopQuantity"); BigDecimal invoiceTotal = ((BigDecimal) event.get("platformPrice")) .multiply(new BigDecimal((int) event.get("platformQuantity"))); invoiceTotal = invoiceTotal.add(((BigDecimal) event.get("middlewarePrice")) .multiply(new BigDecimal((int) event.get("middlewareQuantity")))); invoiceTotal = invoiceTotal.add(((BigDecimal) event.get("workshopPrice")) .multiply(new BigDecimal((int) event.get("workshopQuantity")))); Map<String, Object> invoice = new HashMap<>(); invoice.put("date", (Date) event.get("date")); invoice.put("deliveryMatrixId", (long) event.get("deliveryMatrixId")); invoice.put("hoursTotal", totalHours); invoice.put("invoiceTotal", invoiceTotal); invoice.put("invoiceRequest", (String) event.get("invoiceRequest")); boolean confirmed = false; if (event.containsKey("invoiceNumber")) { invoice.put("invoiceNumber", (String) event.get("invoiceNumber")); invoice.put("invoiceStatus", InvoiceStatus.CONFIRMED.toString()); confirmed = true;//from w ww . j a v a 2 s . c o m } else { invoice.put("invoiceNumber", null); invoice.put("invoiceStatus", InvoiceStatus.REQUESTED.toString()); } invoice.put("deliveryMatrixId", (long) event.get("deliveryMatrixId")); // get opportunity Map<String, Object> opportunityRequest = new HashMap<>(); opportunityRequest.put("deliveryMatrixId", (long) event.get("deliveryMatrixId")); Map<String, Object> opportunity = opportunityPersistanceService.findBy(opportunityRequest); opportunityRequest.clear(); opportunityRequest.put("id", (long) opportunity.get("id")); Map<String, Object> opportunityHours = opportunityPersistanceService .listOpportunityHours(opportunityRequest); List<Map<String, Object>> hoursList = (List<Map<String, Object>>) opportunityHours.get("list"); // verificar horas for (Map<String, Object> oHours : hoursList) { HourType type = HourType.valueOf((String) oHours.get("hourType")); int aviableHours = (int) oHours.get("quantity") - (int) oHours.get("hoursToBill"); if ((int) event.get(type.toString().toLowerCase() + "Quantity") > aviableHours) { // mas horas de las disponibles response.put("status", EventStatus.EXCEPTION); return response; } } // save invoice Map<String, Object> saveInvoice = invoicePersistanceService.saveInvoice(invoice); if ((EventStatus) saveInvoice.get("status") != EventStatus.SUCCESS) { response.put("status", EventStatus.EXCEPTION); return response; } // update opportunity remaining hours if (confirmed) { opportunity.put("billedHours", (int) opportunity.get("billedHours") + totalHours); } opportunity.put("hoursToBill", (int) opportunity.get("hoursToBill") + totalHours); Map<String, Object> updateOpportunity = opportunityPersistanceService.updateOpportunity(opportunity); if ((EventStatus) updateOpportunity.get("status") != EventStatus.SUCCESS) { throw new RuntimeException("Error at save opportunity"); } // add the hours to invoice hours for (HourType t : HourType.values()) { if ((int) event.get(t.toString().toLowerCase() + "Quantity") < 1) continue; Map<String, Object> hour = new HashMap<>(); hour.put("invoiceOrder", (long) saveInvoice.get("id")); hour.put("quantity", (int) event.get(t.toString().toLowerCase() + "Quantity")); hour.put("hourType", t.toString()); hour.put("unitPrice", (BigDecimal) event.get(t.toString().toLowerCase() + "Price")); hour.put("amount", ((BigDecimal) hour.get("unitPrice")).multiply(new BigDecimal((int) hour.get("quantity")))); Map<String, Object> saveHour = invoicePersistanceService.saveInvoiceHours(hour); if ((EventStatus) saveHour.get("status") != EventStatus.SUCCESS) { response.put("status", EventStatus.EXCEPTION); return response; } // update opportunity hours for (Map<String, Object> oHours : hoursList) { HourType type = HourType.valueOf((String) oHours.get("hourType")); if (type == t) { if (confirmed) { oHours.put("billedHours", (int) oHours.get("billedHours") + (int) hour.get("quantity")); } oHours.put("hoursToBill", (int) oHours.get("hoursToBill") + (int) hour.get("quantity")); Map<String, Object> updateOpportunityHours = opportunityPersistanceService .updateOpportunityHours(oHours); logger.debug("updatr response " + updateOpportunityHours); if ((EventStatus) updateOpportunityHours.get("status") != EventStatus.SUCCESS) { throw new RuntimeException("Error at update opportunity hours"); } break; } } } if (event.containsKey("pdf")) { Map<String, Object> pdf = new HashMap<>(); pdf.put("mimetype", "application/pdf"); pdf.put("data", (byte[]) event.get("pdf")); Map<String, Object> saveAttachment = invoicePersistanceService.saveInvoiceAttachments(pdf); if ((EventStatus) saveAttachment.get("status") != EventStatus.SUCCESS) { response.put("status", EventStatus.EXCEPTION); return response; } } if (event.containsKey("xml")) { Map<String, Object> pdf = new HashMap<>(); pdf.put("mimetype", "application/xml"); pdf.put("data", (byte[]) event.get("xml")); Map<String, Object> saveAttachment = invoicePersistanceService.saveInvoiceAttachments(pdf); if ((EventStatus) saveAttachment.get("status") != EventStatus.SUCCESS) { response.put("status", EventStatus.EXCEPTION); return response; } } response.put("status", com.redhat.rhtracking.events.EventStatus.SUCCESS); return response; }
From source file:com.opensourcestrategies.financials.accounts.GLAccountInTree.java
/** * Gets the debit of this GL account given child GL account. * @param childAccount a <code>GLAccountInTree</code> value * @return a <code>BigDecimal</code> value *//*from w ww .j av a 2 s .c o m*/ private BigDecimal getDebitOfChildrenRec(GLAccountInTree childAccount) { if (childAccount == null) { return BigDecimal.ZERO; } BigDecimal debitOfChildren = BigDecimal.ZERO; if (childAccount.isDebitAccount) { debitOfChildren = childAccount.balance; } for (GLAccountInTree grandchildAccount : childAccount.childAccounts) { debitOfChildren = debitOfChildren.add(getDebitOfChildrenRec(grandchildAccount)); } return debitOfChildren; }
From source file:com.google.enterprise.connector.salesforce.storetype.DBStore.java
public void setDocList(String checkpoint, String str_store_entry) { DatabaseMetaData dbm = null;//from w w w . j ava 2 s. c o m Connection connection = null; logger.log(Level.FINEST, "Setting doclist " + checkpoint); logger.log(Level.FINEST, "Setting store_entry " + str_store_entry); try { connection = ds.getConnection(); connection.setAutoCommit(true); dbm = connection.getMetaData(); //logger.log(Level.FINE,"Base64 ENCODING..."); String encode_entry = new String( org.apache.commons.codec.binary.Base64.encodeBase64(str_store_entry.getBytes())); str_store_entry = encode_entry; //logger.log(Level.FINE,"Setting store_entry ENCODED " + str_store_entry); if (dbm.getDatabaseProductName().equals("MySQL")) { //get the most recent row Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); String update_stmt = "select crawl_set from " + this.instance_table + " where crawl_set=(select max(crawl_set) from " + this.instance_table + ")"; logger.log(Level.FINE, "Getting lastentryp in db: " + update_stmt); ResultSet rs = statement.executeQuery(update_stmt); boolean ret_rows = rs.first(); String last_entry_in_db = null; while (ret_rows) { BigDecimal crawl_set = rs.getBigDecimal("crawl_set"); last_entry_in_db = crawl_set.toPlainString(); ret_rows = rs.next(); } logger.log(Level.FINER, "Last_Entry_in_Database " + last_entry_in_db); if (last_entry_in_db != null) { if (last_entry_in_db.startsWith(checkpoint)) { //increment if in the same set BigDecimal bd = new BigDecimal(last_entry_in_db); bd = bd.add(new BigDecimal(".00001")); logger.log(Level.INFO, "Adding to DBStore. Index Value: " + bd.toPlainString()); update_stmt = "insert into " + this.instance_table + " (crawl_set,crawl_data) values (?,COMPRESS(?))"; PreparedStatement ps = connection.prepareStatement(update_stmt); ps.setString(1, bd.toPlainString()); ps.setString(2, str_store_entry); ps.executeUpdate(); ps.close(); } else { //otherwise add the the 0th row for this set logger.log(Level.INFO, "Adding to DBStore. Index Value: " + checkpoint + ".00000"); update_stmt = "insert into " + this.instance_table + " (crawl_set,crawl_data) values (?,COMPRESS(?))"; PreparedStatement ps = connection.prepareStatement(update_stmt); ps.setString(1, checkpoint + ".00000"); ps.setString(2, str_store_entry); ps.executeUpdate(); ps.close(); } } else { logger.log(Level.INFO, "Adding to DBStore. Index Value: " + checkpoint + ".00000"); update_stmt = "insert into " + this.instance_table + " (crawl_set,crawl_data) values (?,COMPRESS(?))"; PreparedStatement ps = connection.prepareStatement(update_stmt); ps.setString(1, checkpoint + ".00000"); ps.setString(2, str_store_entry); ps.executeUpdate(); ps.close(); } rs.close(); statement.close(); connection.close(); } } catch (Exception ex) { logger.log(Level.SEVERE, "Exception initializing context Datasource " + ex); return; } }