I am using a ResultSet and would like to make sure i close it and set to null when done. I would like to do something along the lines of the following: ResultSet rs; try { ... rs = theStatement.executeQuery(sqlStmt); } catch (Exception ex) { ... } finally { if (rs != null) { rs.close(); rs = null; } } problem is I get an compile error that rs might not have been initialized. I cannot declare/instantiate rs outside of the try since it is an interface (ResultSet rs = new ResultSet() NOT LEGEL!). How do I do this :} thanks in advance paul wetzel ------------------
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
Change the first line to: <pre> ResultSet rs = null;</pre> That's sufficient for it to be "initialized" as far as the compiler is concerned.