cancel
Showing results for 
Search instead for 
Did you mean: 

error while fetching the values from database

Former Member
0 Kudos

hiii all,

I have a dynpro project where i am using JDBC codes to fetch data from tables. I have used 2SQL queries...in the first query i am fetching values from 2tables and taking the result from this i run another query.As a result i expect 19591 records as the output....

1)when i put while loop for 19000, 19000records are being within 1min.....

2)when i put while loop for 20000, exception is thrown as :

ArrayIndexOutOfboundsException : size:19591,i:19591

i is variable for while loop

3)when i dont put any condition for while loop, itz taking unlimited time and output is not displayed....

please do help out...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The problem seems that you are trying to fetch a record by giving a count that doesnot exist in the database.

Try to get the table count and instead of using a hard-coded value like 20000, use this value in the condition for ' for-loop'.

Also without a condition the for -loop is expected to take a long time till the application gives a time-out error.

Regards,

Sudeep

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

change your while loop as follows

rs is an object of resultset

while(rs.next())

{

// do what you are doing

}

If this doesnt help pl post your code.

Regards

Ayyapparaj

Former Member
0 Kudos

hii sudip n appa,

my code is

-


while(group_rs1.next())

{

arr_joint_id.add((group_rs1.getString(1)));

arr_line_id.add(group_rs1.getString(2));

index1++;

// if(index1==19000)

// {

// break;

// }

}

the values stored in arraylist arr_joint_id is used to fetch the records from the query below...

for(int i = 0; i <arr_joint_id.size(); i++)

{

String joint_id = arr_joint_id.get(i).toString();

group_rs = group_st.executeQuery("SELECT A.SIZE_NBMM,A.ISFIELDJOINT,A.WELDTEST_CRI_ID,D.TESTLEVELNO,E.COMPLETE FROM EALPS_DRWREVSPLJTS A,EALPS_WELDTESTCRIT D,EALPS_ACTV_SEQ E WHERE"

+ " A.JOINT_ID='" + joint_id +"' OR D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID OR E.JOINT_ID=A.JOINT_ID");

}

int index = 0;

while(group_rs.next())

{

//wdComponentAPI.getMessageManager().reportSuccess("inside while loop");

arr_size.add(new Float(group_rs.getFloat(1)));

arr_isfieldjoint.add(group_rs.getString(2));

arr_weldtest_cri_id.add(new Long(group_rs.getLong(3)));

arr_testlevelno.add(group_rs.getString(4));

arr_complete.add(group_rs.getString(5));

index++;

// if(index==19000)

// {

// break;

// }

}

here i have commented for index=19000

Please do go thru the code n advise...

Former Member
0 Kudos

Hi,

Can you explain what you are trying to acheive?

What is the purpose of this code

// if(index1==19000)

// {

// break;

// }

Following statement will exceute till the size of the array and execute query but you are using only the last one.

for(int i = 0; i <arr_joint_id.size(); i++)

{

String joint_id = arr_joint_id.get(i).toString();

group_rs = group_st.executeQuery("SELECT A.SIZE_NBMM,A.ISFIELDJOINT,A.WELDTEST_CRI_ID,D.TESTLEVELNO,E.COMPLETE FROM EALPS_DRWREVSPLJTS A,EALPS_WELDTESTCRIT D,EALPS_ACTV_SEQ E WHERE"

+ " A.JOINT_ID='" + joint_id +"' OR D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID OR E.JOINT_ID=A.JOINT_ID");

}

int index = 0;

while(group_rs.next())

All this will lead to a big performance issue.

Regards

Ayyapparaj

srinivas_sistu
Active Contributor
0 Kudos

Hi,

this is a part of your code..

for(int i = 0; i <arr_joint_id.size(); i++)

{

String joint_id = arr_joint_id.get(i).toString();

group_rs = group_st.executeQuery("SELECT A.SIZE_NBMM,A.ISFIELDJOINT,A.WELDTEST_CRI_ID,D.TESTLEVELNO,E.COMPLETE FROM EALPS_DRWREVSPLJTS A,EALPS_WELDTESTCRIT D,EALPS_ACTV_SEQ E WHERE"

+ " A.JOINT_ID='" + joint_id +"' OR D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID OR E.JOINT_ID=A.JOINT_ID");

}

int index = 0;

while(group_rs.next())

{

//wdComponentAPI.getMessageManager().reportSuccess("inside while loop");

arr_size.add(new Float(group_rs.getFloat(1)));

arr_isfieldjoint.add(group_rs.getString(2));

it means you are performing a databaseoperation of SELECT .... on the last record from your for loop, I maen you are doing a SELECT on

SELECT A.SIZE_NBMM,A.ISFIELDJOINT,A.WELDTEST_CRI_ID,D.TESTLEVELNO,E.COMPLETE FROM EALPS_DRWREVSPLJTS A,EALPS_WELDTESTCRIT D,EALPS_ACTV_SEQ E WHERE"

+ " A.JOINT_ID=

'" arr_joint_id.get(lenght-1).toString()"'

OR D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID OR E.JOINT_ID=A.JOINT_ID"

Means you are using a for loop to get the last record inside your arraylist and store it in a variable and for that value you are doing a SELECT and for the results from SELECT you are doing a while(rs.next())....

menas you dont need all the other entries inside your "arr_joint_id" ????

Regards,

Srinivas.

Former Member
0 Kudos

group_rs1 = group_st1.executeQuery("SELECT A.JOINT_ID,C.LINE_ID FROM EALPS_DRWREVSPLJTS A,EALPS_DRW_REV_SPL B,EALPS_DRW_REV_LINE C WHERE"

+ " B.SPOOL_ID=A.SPOOL_ID AND B.LINE_ID=C.LINE_ID");

//group_rs1=group_st1.executeQuery("SELECT D.TESTLEVELNO FROM EALPS_EALPS_DRWREVSPLJTS A,WELDTESTCRIT D WHERE D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID ");

//wdComponentAPI.getMessageManager().reportSuccess("connection.toString ="+conn.toString());

int index1=0;

while(group_rs1.next())

{

arr_joint_id.add((group_rs1.getString(1)));

arr_line_id.add(group_rs1.getString(2));

index1++;

}

for(int i = 0; i <arr_joint_id.size(); i++)

{

String joint_id = arr_joint_id.get(i).toString();

group_rs = group_st.executeQuery("SELECT A.SIZE_NBMM,A.ISFIELDJOINT,A.WELDTEST_CRI_ID,D.TESTLEVELNO,E.COMPLETE FROM EALPS_DRWREVSPLJTS A,EALPS_WELDTESTCRIT D,EALPS_ACTV_SEQ E WHERE"

+ " A.JOINT_ID='" + joint_id +"' OR D.WELD_TEST_CRIT_ID=A.WELDTEST_CRI_ID OR E.JOINT_ID=A.JOINT_ID");

}

int index = 0;

while(group_rs.next())

{

//wdComponentAPI.getMessageManager().reportSuccess("inside while loop");

arr_size.add(new Float(group_rs.getFloat(1)));

arr_isfieldjoint.add(group_rs.getString(2));

arr_weldtest_cri_id.add(new Long(group_rs.getLong(3)));

arr_testlevelno.add(group_rs.getString(4));

arr_complete.add(group_rs.getString(5));

index++;

}

thanks a lot for pointing out my mistake that i was taking the last resultset and performing operations on that only....

please go thru my code,i have changed them....now i am taking all the values from each of the record-sets...............but now itz taking infinite time after which the page is exprining....can u plzz suggest.............