String[] Starttime= new String[5000];
String[] Endtime = new String[5000];
int st=0;
int et=0;
while(rs.next()) {           
    ResultSet rs_second=stmt.executeQuery("*Select Query*");
    while (rs_second.next()) {
        if(condition){
            rs_second.previous();
            Endtime[et]=rs_second.getString("rec_datetime");
            rs_second.next();
            et=et+1;
        }
        else if(condition){
            Starttime[st]=rs_second.getString("rec_datetime");
            st=st+1;
        }
    }
    System.out.println();
    System.out.println(st);
    System.out.println(et);
    for(int i=0;i<st;i++) {
        Date Start=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(Starttime[i]);
        Date End=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(Endtime[i]);
        long diff = End.getTime() - Start.getTime();
        long diffSeconds = diff / 1000 % 60;
        long diffMinutes = diff / (60 * 1000) % 60;
        long diffHours = diff / (60 * 60 * 1000) % 24;
        long diffDays = diff / (24 * 60 * 60 * 1000);
        System.out.println(diffDays+" Days "+diffHours +" Hours "+diffMinutes+" Minutes "+diffSeconds+" Seconds");
    }
} 
When the above code is executed, at first the code runs absolutely fine, but when accessing rs.next() again. its showing:
java.lang.NullPointerException
    at oracle.jdbc.driver.ScrollableResultSet.next(ScrollableResultSet.java:344)
    at triage.Triage.main(Triage.java:84)
I tried to execute rs.next() separately, and it contains 17 records.
Tried with everything but not able to debug the exception.
This question is not a duplicate of What is a nullpointerexception and how do I fix it 
In this case I cannot debug why it's coming, since the code is running absolutely fine once and when while(rs.next()) is encountered second time, null pointer exception is caused.
 
     
    