Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners problem with Vector elemenAt()::ArrayIndexOutofBoundsException
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


B.sucharitha
problem with Vector elemenAt()::ArrayIndexOutofBoundsException
0 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners


Hi,

I am execute a query and add resultset data to a vector like bellow

try{
                        ps2 = liveDB.getPreparedStatement(queryforGroups);
                        ps2.setInt(1, ext);
                        ps2.setInt(2, _siteid);
                        rs2 = ps2.executeQuery();
                        System.out.println("22222222222222queryforGroups::::"+queryforGroups+"ext::"+ext+" _siteid::"+_siteid);
                        if (rs2.next()) {
                            int nacdenabled = rs2.getInt("acdenabled");
                            int npbxenabled = rs2.getInt("extendedgroup");
                            int grptype = rs2.getInt("grouptype");
                            if (nacdenabled == 1) {
                                displayVec.addElement("ACD Group:" + rs2.getString("title"));
                            } else {
                                if (npbxenabled == 1) {
                                    displayVec.addElement("AutoAttendant:" + rs2.getString("title"));
                                }
                                if (grptype == BLAProvisioningManager.BLA_GROUP_TYPE) { // added for BLA
                                    displayVec.addElement("BLA:" + rs2.getString("title"));
                                }
                                if (npbxenabled == 0 && grptype != BLAProvisioningManager.BLA_GROUP_TYPE) {
                                    displayVec.addElement("Group:" + rs2.getString("title"));
                                }
                            }
                        } else {
                            **displayVec.addElement("");**//**I think it may cause Error**
                        }
                        }catch(Exception e){
                            logger.log("1 Exception of rs2,ps2 :" + e,logger.ERROR);
                            System.out.println("1 Exception of rs2,ps2 :" + e);
                        }finally{
                            liveDB.closeConnections(rs2, ps2);
                        }

Now when i am trying to reading data from that vector as bellow::

for (int ni = 0; ni < statename.size(); ni++) { System.out.println("vector::::::"+displayVec.elementAt(ni)); String assignedTo = (String) displayVec.elementAt(ni); System.out.println("assignedTo:::::"+assignedTo);

                                                            String emailid = "";
                                                            if (displayVec.elementAt(ni).toString() != "") {
                                                                emailid = "( " + assignedTo + " )";
                                                            } else {
                                                                emailid = "";
                                                            }
                                                            strdisabled = "";
                                                            disflag = objPhones.isCallerIDforAccount(_siteid, phoneNum.elementAt(ni).toString());
                                                            if (disflag > 0) {
                                                                strdisabled = "disabled";
                                                            }

}

Now I got Exception as shown Bellow:

  • Servlet.service() for servlet jsp threw exception

java.lang.ArrayIndexOutOfBoundsException: 252 >= 252

    at java.util.Vector.elementAt(Vector.java:432)

    at org.apache.jsp.AdminSaaS.FreePhones_jsp._jspService(FreePhones_jsp.java:1105)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

    at java.lang.Thread.run(Thread.java:595)

Please can Any one help me to resolve this?

Thanks, B.Sucharitha.


Advertisement
View Answers

Related Tutorials/Questions & Answers:
 

 

 

DMCA.com