Exception :java.lang.ArrayIndexOutOfBoundsException
<p>I am new to Java. In my program I did oracle connection and I given one select query with <code>rownumber</code> limit. When I give <code>rownum=1000</code>, the program executed normally. When I give <code>rownum=5000</code>, it throws <code>java.lang.ArrayIndexOutOfBoundsException</code></p>

<p>When I searched in Google I got some solution like array has not been initialized, so I initialized it, but same problem.</p>

<p>This is my code:</p>

<pre><code>public class data {

public data()
    {       
        connect();  /* 2nd error in this line number  */
    }

private void connect()
    {    
      String arrpageno[]= sequence.split("\\|");

    /*final value */ int finalvalue=0;

    int arrpagenolen=(arrpageno.length)-1;

    String finalarr[][]=new String[3000000][5];
    int tempreload=0;

    int totalreload=0;
    /*System.out.println("Length="+arrpagenolen);
    for(int s=0;s&lt;arrpagenolen;s++)
    {
    System.out.println(s+"="+arrpageno[s]);
    }*/
    for(int n=0;n&lt;arrpagenolen;n++)
    {
        if(n==0)
        {
            totalreload=Integer.parseInt(arrreload[n]);
            if(totalreload==1)
            {
                finalarr[finalvalue][1]=arrpageno[n];
                finalarr[finalvalue][2]=arrreload[n];
                finalarr[finalvalue][3]=arrtime[tempreload];
                finalarr[finalvalue][4]=arrreferal[n];

            }else
            {
                for(int y=0;y&lt;totalreload;y++)
                {
                    //System.out.println(finalarr[finalvalue][3]);
                    if(finalarr[finalvalue][3]!=null)
                    {
                        int x=Integer.parseInt(finalarr[finalvalue][3]);
                        int g=Integer.parseInt(arrtime[tempreload]);/*1st error in this line */
                        int temp=x+g;
                        finalarr[finalvalue][3]=Integer.toString(temp);
                    }else
                    {
                        if(arrtime[tempreload]!=null)
                        {
                            finalarr[finalvalue][3]=arrtime[tempreload];
                        }else
                        {
                            int tmprl=0;
                            arrtime[tempreload]=Integer.toString(tmprl);
                        }                                       
                    }
                    tempreload++;
                }
                finalarr[finalvalue][1]=arrpageno[n];
                finalarr[finalvalue][2]=arrreload[n];
                finalarr[finalvalue][4]=arrreferal[n];

            }
            finalvalue++;

        }
        else
        {
            int flag=0;
            int selectedindex=0;
            for(int j=0;j&lt;finalvalue;j++)
            {
                int temp1=Integer.parseInt(finalarr[j][1]);
                int temp2=Integer.parseInt(arrpageno[n]);
                if(temp1==temp2)
                {
                    flag=1;
                    selectedindex=j;
                }
            }

            if(flag==0)
            {
                totalreload=Integer.parseInt(arrreload[n]);
                if(totalreload==1)
                {

                    finalarr[finalvalue][1]=arrpageno[n];
                    finalarr[finalvalue][2]=arrreload[n];
                    finalarr[finalvalue][3]=arrtime[tempreload];
                    finalarr[finalvalue][4]=arrreferal[n];
                }
                else
                {
                    for(int y=0;y&lt;totalreload;y++)
                    {
                        if(finalarr[finalvalue][3]!=null)
                        {
                            int x=Integer.parseInt(finalarr[finalvalue][3]);
                            int g=Integer.parseInt(arrtime[tempreload]);
                            System.out.println("g value="+g);
                            int temp3=x+g;
                            System.out.println("temp3 value="+temp3);
                            finalarr[finalvalue][3]=Integer.toString(temp3);
                        }else
                        {
                            finalarr[finalvalue][3]=arrtime[tempreload];
                        }
                        //finalarr[finalvalue][3]=finalarr[finalvalue][3]+arrtime[tempreload];
                        tempreload++;
                    }

                    finalarr[finalvalue][1]=arrpageno[n];
                    finalarr[finalvalue][2]=arrreload[n];
                    finalarr[finalvalue][4]=arrreferal[n];
                }   
                finalvalue++;
            }   
            else
            {
                totalreload=Integer.parseInt(arrreload[n]);
                if(totalreload==1)
                {
                    int x=Integer.parseInt(finalarr[selectedindex][2]);
                    int g=Integer.parseInt(arrreload[n]);
                    int temp4=x+g;
                    finalarr[selectedindex][2]=Integer.toString(temp4);

                    int a=Integer.parseInt(finalarr[selectedindex][3]);
                    //System.out.println("reload 1 previous value "+a);
                    int b=Integer.parseInt(arrtime[tempreload]);
                    //System.out.println("reload 1 new value "+b);
                    int temp5=a+b;
                    //System.out.println("reload 1 temp value "+temp5);
                    finalarr[selectedindex][3]=Integer.toString(temp5);


                }
                else            
                {
                    for(int y=0;y&lt;totalreload;y++)
                    {

                        int x=Integer.parseInt(finalarr[selectedindex][3]);
                        //System.out.println("else previous value "+x);

                        int g=Integer.parseInt(arrtime[tempreload]);
                        //System.out.println("else new value "+g);

                        int temp6 = x+g;
                        //System.out.println("else temp value "+temp6);
                        finalarr[selectedindex][3]=Integer.toString(temp6);
                        tempreload++;
                    }
                    int p=Integer.parseInt(finalarr[selectedindex][2]);
                    int q=Integer.parseInt(arrreload[n]);
                    int temp7=p+q;
                    finalarr[selectedindex][2]=Integer.toString(temp7);


                }
            }
        }
    }

}


public static void main(String[] args)

{
    new data();    /* 3rd error in this line number*/

}

}
</code></pre>

<p>java.lang.ArrayIndexOutOfBoundsException: 34</p>

<pre><code>    at data.connect(data.java:384) /* that is int g=Integer.pa.. error */

    at data.&lt;init&gt;(data.java:78)  /* connect(); */

    at data.main(data.java:534)   /* new data(); */
</code></pre>

<p>Thank you in advance.</p>
