Return statement and Try Catch problem
Hi!!
I've got the next code:
public ResultSet DBSelectTeam(String query) {
try {
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(query);
return rs;
} catch (Exception err) {
JOptionPane.showMessageDialog(null, "ERROR: " + err);
}
}
But I need a return statement in the catch-block, but I don't know what's the best option.
Help...
Many thanks.
[451 byte] By [
link_neta] at [2007-10-2 1:45:34]

I've never used them, but I understand in a case like this, it might be best to use a throwable - and make your method throw something if it fails.
Otherwise, probably the best thing to do is to return the value null. (I don't know if a ResultSet can have the value null, so if it can't then this would not be the thing to do. But if it can, then this would problably be the simplest thing to do)
A lenghtier discussion can be found in the cross-post: http://forum.java.sun.com/thread.jspa?threadID=670338@link_net: Please do not cross-post. You are wasting peoples time, and that's not very nice, don't you agree?
Hi happy_hippo :)Yes, I agree... and I'm sorry :(( I sent my post to this forum (Swing), but later I realized it was better in Java Programming. That's the reason why I followed replying in Java Programming and not in this forum.Sorry again :(