jaggernat
asked on
logic to call back end from java
hi guys
I am trying to figure out a logic for my code scenario.
I have a search screen where user enters range of ids. I have to retrieve information for the range of ids.
for example: 1-100 (i am storing this in string array ids)
i am getting all the id individually and passing each id in my backend query
for(int i=0; i< ids.length ; i++)
{
from jsp--> call middle layer --> call backend and pass 1 to "select * from table where customer_id= 1"
from jsp--> call middle layer --> callbackend and pass 2 to "select * from table where customer_id= 2"
from jsp--> call middle layer --> callbackend and pass 3 to "select * from table where customer_id= 3"
....
....
call backend and pass 100 to "select * from table where customer_id= 100"
}
but the problem is the above approach is taking long time because in above case i am executing 100 queries
so if the range is 1-10000, 10000 queries are executed which takes a very long time.
Is there any other alternative to this.
One of the options is range search, something like
select * from table where customer_id between 1 and 10000
but i dont want to do that because i need to pass indivual ids in the middle layer and then pass each id
to the back end.
Any idea how i can run the above 100 queries and improve the performance.
thanks v much
J
I am trying to figure out a logic for my code scenario.
I have a search screen where user enters range of ids. I have to retrieve information for the range of ids.
for example: 1-100 (i am storing this in string array ids)
i am getting all the id individually and passing each id in my backend query
for(int i=0; i< ids.length ; i++)
{
from jsp--> call middle layer --> call backend and pass 1 to "select * from table where customer_id= 1"
from jsp--> call middle layer --> callbackend and pass 2 to "select * from table where customer_id= 2"
from jsp--> call middle layer --> callbackend and pass 3 to "select * from table where customer_id= 3"
....
....
call backend and pass 100 to "select * from table where customer_id= 100"
}
but the problem is the above approach is taking long time because in above case i am executing 100 queries
so if the range is 1-10000, 10000 queries are executed which takes a very long time.
Is there any other alternative to this.
One of the options is range search, something like
select * from table where customer_id between 1 and 10000
but i dont want to do that because i need to pass indivual ids in the middle layer and then pass each id
to the back end.
Any idea how i can run the above 100 queries and improve the performance.
thanks v much
J
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for confirming what I thought, Ajay. Good to know I was on the right track.