wrote:
> Toby -
>
> Well, I have a class with static utility methods such as:
>
> public static void closeConnection(Connection connection)
> public static void closeStatement(Statement statement)
> public static void closeResultSet(ResultSet resultset)
>
> which, back in the day had a little more utility for getting pooled
> connections for non-bean stuff - I just kept the close calls because it
> keeps me from having try/catch blocks in my finally blocks...
>
> anyway, my beans use JNDI to get the pooled connections now and I was
> continuing to use these static calls, but received rmi errors ( a la
> java.rmi.ServerException: Transaction
> rolledback:com/bebee/recommender/utility/DatabaseUtility ).
>
> So I removed the calls to these static methods and replaced them with
> Connection.close(), etc calls. This stopped the rmi errors. My conclusion
> here was that an ejb calling static methods is apparently a bad thing (makes
> sense since it is trying to circumvent the container, i guess?)
No this should work. This is a pretty common practice. What was the rest
of the trace? There may have been a prior exception that would tell us more.
>
> The next problem was that since I was used to using my utility methods
> (which checked for nulls being passed in) I grew lazy and closed things in
> no particular order which resulted in NullPointerExceptions when I did the
> following:
>
> conn.close();
> preparedstmt.close(); // null pointer here
Or some other exception, or nothing, depending on the driver.
> // interesting point to make here -- no errors on regular statements
> closed here, just prepared ones... seemes rather odd ( i would be interested
> to hear more about this)
Hmmm. Statement caches?
> rs.close();
>
> According to colleagues the 'proper' order for closing this stuff is
> ResultSet then Statement then Connection - so I will take them at their
> word.
With some drivers it won't matter, but I'd do as you're doing. You might
want to make your static helper (once we figure out what's going on with
those) take all three (connection, statement, resultset) as parameters
so it can do it in order. You'd still want other overrides, though.
>
> So in conclusion, I confiused the hell out of myself -- which is good every
> now and again.
Indeed it is!
-danch
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user