List of usage examples for java.sql PreparedStatement toString
public String toString()
From source file:it.fub.jardin.server.DbUtils.java
public int setObjects(final Integer resultsetId, final List<BaseModelData> records, String username) throws HiddenException { int result = 0; Connection connection = this.dbConnectionHandler.getConn(); final String sep = ","; String tableName = null;/*from w w w. ja v a2 s.c o m*/ // String set = ""; try { ResultSetMetaData metadata = this.dbProperties.getResultsetMetadata(connection, resultsetId); tableName = metadata.getTableName(1); connection.setAutoCommit(false); for (BaseModelData record : records) { String set = ""; int columns = record.getPropertyNames().size(); for (String property : record.getPropertyNames()) { set += "`" + property + "`=?" + sep; } set = set.substring(0, set.length() - sep.length()); // String query = // "INSERT INTO `" + tableName + "` SET " + set // + " ON DUPLICATE KEY UPDATE " + set; String query = "INSERT INTO `" + tableName + "` SET " + set; PreparedStatement ps = (PreparedStatement) connection.prepareStatement(query); int i = 1; for (String property : record.getPropertyNames()) { Object value = record.get(property); if ((value != null) && (String.valueOf(value).length() > 0)) { ps.setObject(i, record.get(property)); // ps.setObject(i + columns, record.get(property)); } else { ps.setNull(i, java.sql.Types.NULL); // ps.setNull(i + columns, java.sql.Types.NULL); } i++; } // System.out.println(ps.toString()); int num = ps.executeUpdate(); if (num > 0) { String toLog = "INSERT (" + ps.toString() + ")"; // Log.debug(toLog); JardinLogger.debug(username, toLog); } result += num; } connection.commit(); connection.setAutoCommit(true); } catch (MySQLIntegrityConstraintViolationException ex) { try { connection.rollback(); } catch (Exception e) { // TODO Auto-generated catch block JardinLogger.debug(username, "Errore SQL: impossibile eseguire rollback transazione"); e.printStackTrace(); } String message = ex.getLocalizedMessage(); String newMess = ""; // Log.warn("Errore SQL", ex); if (ex.getErrorCode() == 1062) { // updateObjects(resultsetId, records); newMess = newMess.concat(ex.getErrorCode() + " - Errore!!! \n PRIMARY KEY DUPLICATA :\n" + message); } else if (ex.getErrorCode() == 1048) { newMess = newMess .concat(ex.getErrorCode() + " - Errore!!! \n VINCOLO DI INTEGRITA' VIOLATO :\n" + message); } else if (ex.getErrorCode() == 1452) { newMess = newMess .concat(ex.getErrorCode() + " - Errore!!! \n VINCOLO DI FOREIGN KEY VIOLATO :\n" + message); } else { newMess = ex.getErrorCode() + " - Errore!!! \n Problemi sui dati da salvare :\n" + message; } JardinLogger.debug(username, "Errore SQL: " + newMess); throw new HiddenException(newMess); } catch (Exception e) { try { JardinLogger.error(username, "Errore SQL: impossibile eseguire rollback transazione"); connection.rollback(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Log.warn("Errore SQL", e); throw new HiddenException("Errore durante il salvataggio delle modifiche:\n" + e.getLocalizedMessage()); } finally { // JardinLogger.info("Records setted"); this.dbConnectionHandler.closeConn(connection); } return result; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the operation name by id.//w ww. ja v a2 s .c o m * * @param operationId the operation id * @return the operation name by id * @throws Exception the exception */ public String getOperationNameById(int operationId) throws Exception { Connection connection = null; PreparedStatement ps = null; ResultSet results = null; String operationName = null; StringBuilder sql = new StringBuilder(); sql.append("SELECT operation FROM ").append(HostObjectConstants.API_OPERATION_TYPES_TABLE) .append(" WHERE operation_id=?"); try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = connection.prepareStatement(sql.toString()); log.debug("getOperationName for operationID---> " + operationId); ps.setInt(1, operationId); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); while (results.next()) { operationName = results.getString("operation"); } } catch (Exception e) { handleException("getOperationNameById", e); } finally { DbUtils.closeAllConnections(ps, connection, results); } return operationName; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the response time for api./*from w w w. ja v a 2 s. c o m*/ * * @param apiVersion the api version * @return the response time for api * @throws Exception the exception */ public String getResponseTimeForAPI(String apiVersion) throws Exception { Connection connection = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); sql.append("select * from ").append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject()) .append(" where api_version=? order by time desc limit 1;"); Map<String, Integer> apiCount = new HashMap<String, Integer>(); try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = connection.prepareStatement(sql.toString()); log.debug("getResponseTimeForAPI for apiVersion---> " + apiVersion); ps.setString(1, apiVersion); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); while (results.next()) { return results.getString("serviceTime"); } } catch (Exception e) { handleException("getResponseTimeForAPI", e); } finally { DbUtils.closeAllConnections(ps, connection, results); } return null; }
From source file:swp.bibjsf.persistence.Data.java
/** * Inserts <code>object</code> into <code>table</code> retrieving all fields * of the object. Only those objects are actually stored that are not listed * in <code>toIgnore</code>. If a field is found in <code>replace</code>, * the corresponding replacement value in <code>replace</code> is used * instead of the actual value of the field. Otherwise the field's value is * stored.//from w w w.ja va 2 s.co m * * @param table * name of the table in which <code>object</code> is inserted * @param object * the object to be stored * @param toIgnore * field names that should not be stored * @param replace * values to be replaced for storing * @throws SQLException * thrown in case the object cannot be inserted */ private void insert(String table, Object object, Set<String> toIgnore, HashMap<String, Object> replace) throws SQLException { logger.debug("insert into table " + table); StringBuilder fields = new StringBuilder("INSERT INTO " + table + " ("); StringBuilder placeholders = new StringBuilder("VALUES ("); int numberOfFields = 0; // append fields by "field1, field2, ..., fieldN" // append placeholders by "?, ?, ..., ?" // where field1 is a non-static field // count the number of such fields in numberOfFields HashMap<String, Field> fieldsOfObject = Reflection.getTransitiveFields(new HashMap<String, Field>(), object.getClass()); for (Field f : fieldsOfObject.values()) { if (relevantField(toIgnore, f)) { fields.append(f.getName()); fields.append(","); placeholders.append("?,"); numberOfFields++; } } // fields = "INSERT INTO <table> (field1, field2, ..., fieldN," // placeholders = "VALUES (?, ?, ..., ?," if (numberOfFields > 0) { // remove last commas fields.deleteCharAt(fields.length() - 1); placeholders.deleteCharAt(placeholders.length() - 1); // close statement parts fields.append(")"); placeholders.append(")"); // fields = "INSERT INTO <table> (field1, field2, ..., fieldN)" // placeholders = "VALUES (?, ?, ..., ?)" String sqlInsert = fields.toString() + placeholders.toString(); // sqlInsert = "INSERT INTO <table> (field1, field2, ..., fieldN) // VALUES (?, ?, ..., ?)" // now collect the values of object's fields Object[] values = getValues(object, toIgnore, replace, numberOfFields); // sqlInsert is built from fields collected from object, hence, // cannot be tainted and sqlInsert is safe. Connection connection = dataSource.getConnection(); try { PreparedStatement stmt = connection.prepareStatement(sqlInsert); try { // fill parameters of the statement for (int i = 0; i < values.length; i++) { if (values[i] == null) { stmt.setNull(i + 1, java.sql.Types.VARCHAR); } /* * We are currently not using enums. They would need to * be mapped onto int or strings. Here is the code for * the int mapping: * * else if (values[i] instanceof Enum) { // enums are * mapped onto integer Enum e = (Enum)values[i]; * //stmt.setInt(i + 1, e.ordinal()); stmt.setString(i + * 1, values[i].toString()); * * Yet, the conversion back from the database to the * bean is more complicated. We would need to provide * our own BeanHandler for this conversion. } */ else { stmt.setObject(i + 1, values[i]); } logger.debug( "parameter " + i + ": " + ((values[i] == null) ? "NULL" : values[i].toString())); } logger.debug("stmt = " + stmt.toString()); stmt.executeUpdate(); } finally { stmt.close(); } } finally { connection.close(); } } else { // we treat this as an error; it does not make sense to insert an // object with no fields throw new SQLException("entity " + object + " has no fields"); } }
From source file:it.fub.jardin.server.DbUtils.java
public Integer updateObjects(final Integer resultsetId, final List<BaseModelData> newItemList, final String condition, String username) throws HiddenException { // JardinLogger.info("Updating records..."); int result = 0; Connection connection = this.dbConnectionHandler.getConn(); final String sep = ","; boolean defaultPrimaryKeys = condition.equalsIgnoreCase("$-notspec-$"); try {// w w w. ja va 2s . co m ResultSetMetaData metadata = this.dbProperties.getResultsetMetadata(connection, resultsetId); String tableName = metadata.getTableName(1); // TODO Creare un oggetto per la memorizzazione colonna->valore List<BaseModelData> PKs = this.dbProperties.getResultsetPrimaryKeys(resultsetId); String PKset = ""; connection.setAutoCommit(false); for (BaseModelData record : newItemList) { boolean conditionFounded = false; if (defaultPrimaryKeys) { conditionFounded = true; // richiesta di update da griglia o dettaglio for (BaseModelData pk : PKs) { PKset += (String) pk.get("PK_NAME") + "=? AND "; } PKset = PKset.substring(0, PKset.length() - 5); // Strips // " AND " } else { PKset = condition + "=? "; } String set = ""; Collection<String> properties = record.getPropertyNames(); for (String property : properties) { if (property.equalsIgnoreCase(condition)) { conditionFounded = true; } else { set += "`" + property + "`=? " + sep; } } if (!conditionFounded) { throw new VisibleException("condizione di UPDATE non trovata nel file"); } set = set.substring(0, set.length() - sep.length()); String query = "UPDATE `" + tableName + "` SET " + set + " WHERE " + PKset; PreparedStatement ps = (PreparedStatement) connection.prepareStatement(query); int i = 1; /* Set prepared statement values for changing fields */ for (String property : properties) { if (!property.equalsIgnoreCase(condition)) { i += this.putJavaObjectInPs(ps, i, record.get(property)); } } /* Set prepared statement values for where condition fields */ if (defaultPrimaryKeys) { for (BaseModelData pk : PKs) { Object value = record.get((String) pk.get("PK_NAME")); i += this.putJavaObjectInPs(ps, i, value); } } else { Object value = record.get(condition); i += this.putJavaObjectInPs(ps, i, value); } // Log.debug("Query UPDATE: " + ps); JardinLogger.debug(username, "UPDATE (" + ps.toString() + ")"); int num = ps.executeUpdate(); if (num > 0) { JardinLogger.debug(username, "UPDATE (" + ps.toString() + ")"); } result += num; } connection.commit(); connection.setAutoCommit(true); // JardinLogger.info("Records updated"); } catch (Exception e) { try { connection.rollback(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Log.warn("Errore SQL", e); e.printStackTrace(); throw new HiddenException("Errore durante l'aggiornamento del record:\n" + e.getLocalizedMessage()); } finally { this.dbConnectionHandler.closeConn(connection); } return result; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the details of subscription./*from w w w . j a va 2 s . co m*/ * * @param applicationId the application id * @param apiId the api id * @return the details of subscription * @throws Exception the exception */ public List<OperatorDetailsEntity> getDetailsOfSubscription(int applicationId, int apiId) throws Exception { Connection connection = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); sql.append("SELECT rate_id_nb,operation_id FROM ").append(HostObjectConstants.SUBSCRIPTION_RATES_TABLE) .append(" WHERE application_id=? AND api_id=? "); List<OperatorDetailsEntity> operatorDetails = new ArrayList<OperatorDetailsEntity>(); try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = connection.prepareStatement(sql.toString()); log.debug("getOperatorDetailsOfSubscription for applicationId---> " + applicationId + " apiId--> " + apiId); ps.setInt(1, applicationId); ps.setInt(2, apiId); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); log.debug("REPORTS DEBUG LOGS 00 : ps = " + ps); while (results.next()) { OperatorDetailsEntity detailsEntity = new OperatorDetailsEntity(); detailsEntity.setRateName(results.getString("rate_id_nb")); detailsEntity.setOperationId(Integer.parseInt(results.getString("operation_id"))); detailsEntity.setOperatorName("__default__"); operatorDetails.add(detailsEntity); } } catch (Exception e) { handleException("getDetailsOfSubscription", e); } finally { DbUtils.closeAllConnections(ps, connection, results); } return operatorDetails; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the operator details of subscription. * * @param applicationId the application id * @param apiId the api id//from ww w .ja v a2s. c o m * @return the operator details of subscription * @throws Exception the exception */ public List<OperatorDetailsEntity> getOperatorDetailsOfSubscription(int applicationId, int apiId) throws Exception { Connection connection = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); sql.append("SELECT operator_name,rate_id_sb,operation_id FROM ") .append(HostObjectConstants.SUBSCRIPTION_OPCO_RATES_TABLE) .append(" WHERE application_id=? AND api_id=? "); List<OperatorDetailsEntity> operatorDetails = new ArrayList<OperatorDetailsEntity>(); try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ; ps = connection.prepareStatement(sql.toString()); log.debug("getOperatorDetailsOfSubscription for applicationId---> " + applicationId + " apiId--> " + apiId); ps.setInt(1, applicationId); ps.setInt(2, apiId); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); while (results.next()) { OperatorDetailsEntity detailsEntity = new OperatorDetailsEntity(); detailsEntity.setRateName(results.getString("rate_id_sb")); detailsEntity.setOperationId(results.getInt("operation_id")); detailsEntity.setOperatorName(results.getString("operator_name")); operatorDetails.add(detailsEntity); } } catch (Exception e) { handleException("getOperatorDetailsOfSubscription", e); } finally { DbUtils.closeAllConnections(ps, connection, results); } return operatorDetails; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the all response times for api.// w w w. j a va 2s .c om * * @param operator the operator * @param appId the app id * @param apiVersion the api version * @param fromDate the from date * @param toDate the to date * @return the all response times for api * @throws Exception the exception */ public List<APIResponseDTO> getAllResponseTimesForAPI(String operator, String appId, String apiVersion, String fromDate, String toDate) throws Exception { String appConsumerKey = "%"; if (operator.contains("__ALL__")) { operator = "%"; } if (!appId.contains("__ALL__")) { appConsumerKey = getConsumerKeyByAppId(appId); } Connection connection = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); sql.append( "select api_version,response_count AS count, serviceTime,STR_TO_DATE(time,'%Y-%m-%d') as date FROM ") .append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject()) .append(" WHERE api_version=? AND (time BETWEEN ? AND ?) AND operatorId LIKE ? AND consumerKey LIKE ?;"); List<APIResponseDTO> responseTimes = new ArrayList<APIResponseDTO>(); try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = connection.prepareStatement(sql.toString()); log.debug("getAllResponseTimesForAPI for apiVersion---> " + apiVersion); ps.setString(1, apiVersion); ps.setString(2, fromDate + " 00:00:00"); ps.setString(3, toDate + " 23:59:59"); ps.setString(4, operator); ps.setString(5, appConsumerKey); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); while (results.next()) { APIResponseDTO resp = new APIResponseDTO(); resp.setApiVersion(results.getString("api_version")); resp.setResponseCount(results.getInt("count")); resp.setServiceTime(results.getInt("serviceTime")); resp.setDate(results.getDate("date")); responseTimes.add(resp); } } catch (Exception e) { handleException("getAllResponseTimesForAPI", e); } finally { DbUtils.closeAllConnections(ps, connection, results); } return responseTimes; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
/** * Gets the total api traffic for line chart. * * @param fromDate the from date/*from w w w.jav a 2 s .co m*/ * @param toDate the to date * @param subscriber the subscriber * @param operator the operator * @param applicationId the application id * @param api the api * @return the total api traffic for line chart * @throws Exception the exception */ public List<String[]> getTotalAPITrafficForLineChart(String fromDate, String toDate, String subscriber, String operator, int applicationId, String api) throws Exception { String consumerKey = null; if (subscriber.equals("__ALL__")) { subscriber = "%"; } if (operator.equals("__ALL__")) { operator = "%"; } if (applicationId == 0) { consumerKey = "%"; } else { consumerKey = apiManagerDAO.getConsumerKeyByApplication(applicationId); } if (api.equals("__ALL__")) { api = "%"; } if (consumerKey == null) { return null; } Connection conn = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); sql.append("select date(time) as date, sum(response_count) hits from ") .append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject()) .append(" where DATE(time) between STR_TO_DATE(?,'%Y-%m-%d') and STR_TO_DATE(?,'%Y-%m-%d') AND operatorId LIKE ? AND userId LIKE ? AND API LIKE ? AND consumerKey LIKE ? ") .append("group by date"); List<String[]> api_request = new ArrayList<String[]>(); try { conn = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = conn.prepareStatement(sql.toString()); ps.setString(1, fromDate); ps.setString(2, toDate); ps.setString(3, operator); ps.setString(4, subscriber); ps.setString(5, api); ps.setString(6, consumerKey); if (log.isDebugEnabled()) { log.debug("getTotalTrafficForLineChart : SQL " + ps.toString()); } results = ps.executeQuery(); while (results.next()) { String[] temp = { results.getDate(1).toString(), results.getString(2) }; api_request.add(temp); } } catch (Exception e) { handleException("getTotalAPITrafficForLineChart", e); } finally { DbUtils.closeAllConnections(ps, conn, results); } return api_request; }
From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java
public static List<String[]> getAPIWiseTrafficForReportWallet(String fromDate, String toDate, String subscriber, String operator, String api, boolean isError) throws Exception { if (subscriber.equals("__ALL__")) { subscriber = "%"; }// w w w .j ava 2 s.co m if (operator.equals("__ALL__")) { operator = "%"; } if (api.equals("__ALL__")) { api = "%"; } String responseStr = "responseCode LIKE '20_' "; if (isError) { responseStr = "responseCode NOT LIKE '20_' "; } String[] fromDateArray = fromDate.split("-"); String[] toDateArray = toDate.split("-"); boolean isSameYear = fromDateArray[0].equalsIgnoreCase(toDateArray[0]) ? true : false; boolean isSameMonth = fromDateArray[1].equalsIgnoreCase(toDateArray[1]) ? true : false; Connection conn = null; PreparedStatement ps = null; ResultSet results = null; StringBuilder sql = new StringBuilder(); String userId; sql.append( "SELECT res.time, res.userId, res.operatorId, res.requestId, res.msisdn, res.chargeAmount, res.responseCode, res.jsonBody, res.resourcePath, res.method, res.purchaseCategoryCode, res.api, res.taxAmount , res.channel , res.onBehalfOf, res.description, res.transactionOperationStatus , req.transactionOperationStatus ") .append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject()).append(" res, ") .append(ReportingTable.SB_API_REQUEST_SUMMARY.getTObject()).append(" req ").append("WHERE ") .append(responseStr) .append(" AND res.operatorId LIKE ? AND replace(res.userid,'@carbon.super','') LIKE ? AND res.api LIKE ? AND res.requestId = req.requestId "); if (isSameYear && isSameMonth) { sql.append("AND (res.day between ? and ? ) AND (res.month = ?) AND (res.year = ?) "); } else { sql.append( "AND STR_TO_DATE(res.time,'%Y-%m-%d') between STR_TO_DATE(?,'%Y-%m-%d') and STR_TO_DATE(?,'%Y-%m-%d') "); } List<String[]> api_request = new ArrayList<String[]>(); try { conn = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); ps = conn.prepareStatement(sql.toString()); ps.setString(1, operator); ps.setString(2, subscriber); ps.setString(3, api); log.debug(api); if (isSameYear && isSameMonth) { ps.setInt(4, Integer.parseInt(fromDateArray[2])); ps.setInt(5, Integer.parseInt(toDateArray[2])); ps.setInt(6, Integer.parseInt(fromDateArray[1])); ps.setInt(7, Integer.parseInt(fromDateArray[0])); } else { ps.setString(4, fromDate); ps.setString(5, toDate); } log.debug("getAPIWiseTrafficForReportWallet" + sql); log.debug("SQL (PS) ---> " + ps.toString()); results = ps.executeQuery(); while (results.next()) { String jsonBody = results.getString(8); String requestUrl = results.getString(9); String requestMethod = results.getString(10); String requestapi = results.getString(12); if (results.getString(2) != null && results.getString(2).contains("@")) { userId = results.getString(2).split("@")[0]; } else { userId = results.getString(2); } String dateTime = results.getString(1); if (dateTime == null) { dateTime = ""; } String msisdn = ""; String clientCorelator = ""; String currency = ""; String event_type = ""; String amount = ""; if (!jsonBody.isEmpty()) { try { JSONObject homejson = new JSONObject(jsonBody); if (!homejson.isNull("makePayment")) { JSONObject transactionObject = (JSONObject) homejson.get("makePayment"); if (!transactionObject.isNull("endUserId")) { msisdn = transactionObject.getString("endUserId"); } if (!transactionObject.isNull("clientCorrelator")) { clientCorelator = transactionObject.getString("clientCorrelator"); } if (!transactionObject.isNull("paymentAmount")) { JSONObject paymentAmountoObj = (JSONObject) transactionObject.get("paymentAmount"); if (!paymentAmountoObj.isNull("chargingInformation")) { JSONObject chargingInfoObj = (JSONObject) paymentAmountoObj .get("chargingInformation"); if (!chargingInfoObj.isNull("currency")) { currency = chargingInfoObj.getString("currency"); amount = chargingInfoObj.getString("amount"); } } } } if (!homejson.isNull("refundTransaction")) { JSONObject transactionObject = (JSONObject) homejson.get("refundTransaction"); if (!transactionObject.isNull("endUserId")) { msisdn = transactionObject.getString("endUserId"); } if (!transactionObject.isNull("clientCorrelator")) { clientCorelator = transactionObject.getString("clientCorrelator"); } if (!transactionObject.isNull("paymentAmount")) { JSONObject paymentAmountoObj = (JSONObject) transactionObject.get("paymentAmount"); if (!paymentAmountoObj.isNull("chargingInformation")) { JSONObject chargingInfoObj = (JSONObject) paymentAmountoObj .get("chargingInformation"); if (!chargingInfoObj.isNull("currency")) { currency = chargingInfoObj.getString("currency"); amount = chargingInfoObj.getString("amount"); } } } } } catch (Exception ex) { System.out.println("Unable to read JSON body stored in DB :: " + ex); clientCorelator = ""; } } if (!requestUrl.isEmpty()) { String apitype = findAPIType(requestUrl, requestapi, requestMethod); if (apitype.equalsIgnoreCase("wallet/payment")) { event_type = "Wallet Payment"; } else if (apitype.equalsIgnoreCase("wallet/refund")) { event_type = "Wallet Refund"; } else if (apitype.equalsIgnoreCase("wallet/list")) { event_type = "Wallet List"; } else if (apitype.equalsIgnoreCase("wallet/balance")) { event_type = "Wallet Balance"; } } String[] temp = { dateTime, userId, results.getString(3), event_type, results.getString(4), clientCorelator, results.getString(5), amount, currency, results.getString(7), results.getString(11), results.getString(13), results.getString(14), results.getString(15), results.getString(16), results.getString(17) }; api_request.add(temp); } } catch (Exception e) { System.out.println( "Error occured while getting API wise traffic for report (Charging) from the database" + e); handleException("Error occured while getting API wise traffic for report (Charging) from the database", e); } finally { DbUtils.closeAllConnections(ps, conn, results); } log.debug("end getAPIWiseTrafficForReportCharging"); return api_request; }