+ ResultSet set = null;
+ try {
+ set = conn.createStatement().executeQuery(selectQuery);

Assuming the preceding statement throws an exception ...

+ set.next();
+ int value = set.getInt("maxid") + 1;
+
+ statement.setInt(currentIndex, value);
+
+ request.setAttribute(keys[i].getAttribute("param"), String.valueOf(value));
+ } catch (SQLException sqle){
+ getLogger().warn("There was an error closing the ResultSet", sqle);
+ throw sqle;
+ } finally {
+ set.close();
+ set.getStatement().close();

... one of these last two statements will thrown a NPE, if I'm not mistaken. We should check that set and set.getStatement() are not null, right?

Moreover:

+ getLogger().warn("There was an error closing the ResultSet", sqle);

The exception is not caught while closing the ResultSet, so the message is misleading.

        Ugo

--
Ugo Cei - http://beblogging.com/blojsom/blog/

Attachment: smime.p7s
Description: S/MIME cryptographic signature



Reply via email to