This site requires JavaScript, please enable it in your browser!
Greenfoot back
Harshitha
Harshitha wrote ...

2016/10/19

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0” with

Harshitha Harshitha

2016/10/19

#
if (rs != null) { ArrayOflong adgrpIds = new ArrayOflong(); long msnCmpId = 0; ArrayOfAdGroup adGroups = new ArrayOfAdGroup(); i = 0; Calendar cal = null; while (rs.next()) { if (msnCmpId == 0) { int count = DBConn.getRowCount("select count(*) from " + tname + " WHERE (LOWER(TRIM(COMPONENT_TYPE))=1 or " + "LOWER(TRIM(COMPONENT_TYPE))=1) AND " + tname + ".SE_ADGROUP_ID IS NOT NULL and " + tname + ".SE_CAMPAIGN_ID IS NOT NULL and SE_CAMPAIGN_ID=" + rs.getLong("SE_CAMPAIGN_ID") + " and " + "TRIM(ADGROUP_STATUS) != 'Deleted' AND CHANGE_STATUS=1", conn); adGroups = new ArrayOfAdGroup(); adgrpIds.getLongs().toArray(new Long); adGroups.getAdGroups().toArray(new AdGroup); msnAdgrpInfObj = new MsnAdGroupInfo(); msnAdgrpInfObj.setDBConnection(dbConn); msnAdgrpInfObj.setMsnConnection(busAssInf.getMsnConnection(busAssInf.getCurBusAssSEAccInf().getBusAssSeaEngAccountId())); } if (msnCmpId > 0 && msnCmpId != rs.getLong("SE_CAMPAIGN_ID")) { msnAdgrpInfObj.setAdGroups(adGroups); msnAdgrpInfObj.bulkUpdate(adgrpIds, msnCmpId); adGroups = null; int count = DBConn.getRowCount("select count(*) from " + tname + " WHERE (LOWER(TRIM(COMPONENT_TYPE))=1 or " + "LOWER(TRIM(COMPONENT_TYPE))=1) AND " + tname + ".SE_ADGROUP_ID IS NOT NULL and " + tname + ".SE_CAMPAIGN_ID IS NOT NULL and SE_CAMPAIGN_ID=" + rs.getLong("SE_CAMPAIGN_ID") + "" + " and TRIM(ADGROUP_STATUS) != 'Deleted' AND CHANGE_STATUS=1", conn); adGroups = new ArrayOfAdGroup(); adgrpIds.getLongs().toArray(new Long); adGroups.getAdGroups().toArray(new AdGroup); i = 0; } msnCmpId = rs.getLong("SE_CAMPAIGN_ID"); if (adGroups.getAdGroups().get(i)== null) { adGroups = new ArrayOfAdGroup(); } adGroups.getAdGroups().get(i).setId(Long.valueOf(rs.getLong("SE_ADGROUP_ID"))); adGroups.getAdGroups().get(i).setName(rs.getString("ADGROUP_NAME")); if (rs.getDouble("ADGROUP_CPC") != 0) { Bid bid1 = new Bid(); bid1.setAmount(((rs.getDouble("ADGROUP_CPC") / CommonFunctions.TEN_LAKHS))); adGroups.getAdGroups().get(i).setSearchBid(bid1); // adgroups.setSearchBid(((rs.getDouble("ADGROUP_CPC") / CommonFunctions.TEN_LAKHS))); } else { adGroups.getAdGroups().get(i).setSearchBid(null); } if (rs.getDate("ADGROUP_END_DATE") != null && rs.getDate("ADGROUP_START_DATE").before(rs.getDate("ADGROUP_END_DATE"))) { if (rs.getDate("ADGROUP_START_DATE") != null) { cal = Calendar.getInstance(); cal.setTime(rs.getDate("ADGROUP_START_DATE")); DateConverter dc = new DateConverter(cal); // adgroups.setStartDate(new com.microsoft.bingads.v10.campaignmanagement.Date(dc.getDate(), dc.getMonth(), dc.getYear())); adGroups.getAdGroups().get(i).setStartDate(new com.microsoft.bingads.v10.campaignmanagement.Date()); } if (rs.getDate("ADGROUP_END_DATE") != null) { cal = Calendar.getInstance(); cal.setTime(rs.getDate("ADGROUP_END_DATE")); DateConverter dc = new DateConverter(cal); // adgroups.setEndDate(new com.microsoft.bingads.v10.campaignmanagement.Date(dc.getDate(), dc.getMonth(), dc.getYear())); adGroups.getAdGroups().get(i).setEndDate(new com.microsoft.bingads.v10.campaignmanagement.Date()); } } else if (rs.getDate("ADGROUP_START_DATE") != null) { cal = Calendar.getInstance(); cal.setTime(rs.getDate("ADGROUP_START_DATE")); DateConverter dc = new DateConverter(cal); // adgroups.setStartDate(new com.microsoft.bingads.v10.campaignmanagement.Date(dc.getDate(), dc.getMonth(), dc.getYear())); adGroups.getAdGroups().get(i).setStartDate(new com.microsoft.bingads.v10.campaignmanagement.Date()); } com.microsoft.bingads.v10.campaignmanagement.Date dt = new com.microsoft.bingads.v10.campaignmanagement.Date(); adGroups.getAdGroups().get(i).setStartDate(null); if (rs.getDate("ADGROUP_END_DATE") != null) { cal = Calendar.getInstance(); cal.setTime(rs.getDate("ADGROUP_END_DATE")); DateConverter dc = new DateConverter(cal); // dt = new com.microsoft.bingads.v10.campaignmanagement.Date(dc.getDate(), dc.getMonth(), dc.getYear()); dt = new com.microsoft.bingads.v10.campaignmanagement.Date(); adGroups.getAdGroups().get(i).setEndDate(dt); } else { adGroups.getAdGroups().get(i).setEndDate(null); } byte srch = rs.getString("ADGROUP_SEARCH_NETWORK").equals("On") ? (byte) 1 : (byte) 0; byte cont = rs.getString("ADGROUP_CONTENT_NETWORK").equals("On") ? (byte) 1 : (byte) 0; adGroups.getAdGroups().get(i).setAdDistribution(msnAdgrpInfObj.getAdDistribution(srch, cont)); if (rs.getDouble("CONTENT_CPC") != 0) { Bid bid1 = new Bid(); bid1.setAmount(((rs.getDouble("CONTENT_CPC") / CommonFunctions.TEN_LAKHS))); adGroups.getAdGroups().get(i).setContentMatchBid(bid1); // adgroups.setContentMatchBid(((rs.getDouble("CONTENT_CPC") / CommonFunctions.TEN_LAKHS))); } else { adGroups.getAdGroups().get(i).setContentMatchBid(null); } adGroups.getAdGroups().get(i).setLanguage(null); // adgrpIds = rs.getLong("ADGROUP_ID"); adgrpIds.getLongs().add(i,rs.getLong("ADGROUP_ID")); msnAdgrpInfObj.setCmpId(rs.getLong("CAMPAIGN_ID")); i = i + 1; } if (adGroups != null && adGroups.getAdGroups().toArray().length > 0) { msnAdgrpInfObj.setAdGroups(adGroups); if (msnAdgrpInfObj.bulkUpdate(adgrpIds, msnCmpId)) { log.info("Updated Adgroups information in campaign id :" + msnCmpId); } } }
Super_Hippo Super_Hippo

2016/10/19

#
Use code tags. Show where the error occurs. This will make it much easier to see what could be wrong.
danpost danpost

2016/10/19

#
After the 'int count ...' line (line 11 above), try adding the following line:
1
if (count == 0) continue;
This will prevent any zero-sized arrays from being created. Maybe you should investigate further as to why a zero was being returned by the 'getRowCount' method from DBConn -- or maybe not (I am not sure if this is something that is okay with you or not).
You need to login to post a reply.