On Sab, 8 de Enero de 2005, 7:41, Ugo Cei dijo:
>> + 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.
Thanks Ugo. You are right, I tried to fix it in a second commit:
http://marc.theaimsgroup.com/?l=xml-cocoon-cvs&m=110515609528180&w=2
But still need refactoring. I will review it now.
Best Regards,
Antonio Gallardo.