I want to store result set store two different location separately and use separately.Is that possible?
public void demo(){
/* Result set got from the corpusSentenceRetrive method */
ResultSet rsNew=corpusSentenceRetrive(wordAll);
ArrayList<String> resultSetStore= new ArrayList<String>();
for(int i=0;i<2;i++){
resultSetStore.add(i,rsNew);
}
method1(resultSetStore.get(0));
method2(resultSetStore(1));
}
public void method1(ResultSet rst){
ResultSet rs = rst;
while (rs.next()) {....}
}
public void method2(ResultSet rst){
ResultSet rs = rst;
while (rs.next()) {....}
}
Why this is not work? How separately execute two method? Because of one method execute while statement .I couldn't use other method. That get 0 result set. How can I solve it easiest way?
A ResultSet contains an internal cursor of the location you are reading from. So when the first method is called and finished the cursor is at the end of the available results. So when the second method is called there are no results to check. Before using the results in either method you can call ResultSet.beforeFirst()
to make sure the cursor is in the right place before using it.