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?)
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
// 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)
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.
So in conclusion, I confiused the hell out of myself -- which is good every
now and again.
Hope that helps clear it up.
scott
----- Original Message -----
From: "Toby Allsopp" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 15, 2001 12:51 PM
Subject: Re: [JBoss-user] RE: Error 'closing' a pooled connection (addendum)
> On Tue, May 15, 2001 at 12:19:14PM -0700, <enter name here> wrote:
> > OK. So here is the answer *I* came up with:
> >
> > Rule 1: It is bad to use utility classes with static methods from your
> > beans - I got rmi errors
>
> Please provide some details about this. As it stands it makes no sense.
>
> > Rule 2: Close your DB stuff in this order: ResultSet then Statement the
> > Connection
>
> Hmm, this shouldn't be neccessary. Can you procide some details, such as
> exactly what you were doing to cuase the problems, and exactly what the
> problems were?
>
> Toby.
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user