I am actually trying to fit something like the following in my code which can be found in the link mentioned below the code:
Statement stmt;
ResultSet rs;
boolean done = false;
int i = 0;
while(!done) {
try {
stmt = connections[i].createStatement();
rs = stmt.executeQuery("select * from aTable");
rs.beforeFirst();
while(rs.next()) {
// Do whatever you need with the result set
}
done = true;
} catch(SQLException e) {
// Catch the exception and try with the next connection
i++;
}
}
Link : https://ideone.com/as1XI8
So, I have added int i
& boolean done
variables on Line #83 & 84
Added while loop starting from line 91 and setting done = true in line 380
Finally, I am incrementing the variable i(i++)
on line 389 and closing the while loop on
line 463 with the brace.
After doing this, I am getting an error on line 80 ( starting brace just before int iterations = 0;
) in
Netbeans saying that "missing return statement".
I already have a return statement on line #460 and can't figure out why I am getting this error.
Could anyone please download the code in your Netbeans/Eclipse and let me know what is wrong?
Thanks !!
You need to return after the while loop
is done ! You are return inside the while loop !
Just take your return statement
after one of the braces and see the magic
NOTE Please avoid putting down the whole code (escp. this type of messy code), it becomes a pain to go through it ! Take some time to format and make it human readable
!
Anyone can write codes that machine can read, its important to write codes that humans can read !