Re: JDBC Connection State Management with SQL Exceptions (esp Postgresql)

From: "AV" <avek_nospam_(at)videotron(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org(dot)pgsql-general(at)postgresql(dot)org
Subject: Re: JDBC Connection State Management with SQL Exceptions (esp Postgresql)
Date: 2001-06-22 03:52:50
Message-ID: DizY6.9880$Xi3.527250@weber.videotron.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


"Joseph Weinstein" <joe(at)bea(dot)com> wrote in message
news:3B3277C6(dot)4C9BCA9(at)bea(dot)com(dot)(dot)(dot)
>
>
> John Moore wrote:
.....
> > I am doing transactional work, with multiple statements and then a
commit().
> > I am also doing my own connection pooling, so it is important that I be
able
> > to reliably re-use connections.
>
> Hi. There is a lot of state that can be left with a connection, and a good
> pooling system should do a bunch of cleanup on the connection when it is
> returned to the pool, so it will be ready for the next user. This would
include
> closing all statements and result sets that the previous user may have
created
> but not closed.

What about PreparedConnection pooling?
What is your oppinion on the following code
[design] for such caching within a connection :
( getUsedPstmts() is imaginary method of imaginary
MyConnection interface )

public void returnConnection (Connection con) {
Connection local_con = con;
con = null;
PreparedStatement [] used_pstmt = (MyConnection) local_con.getUsedPstmts()
for (int i =0 ; i < used_con.length ; i++) {
PreparedStatement new_pstmt = used_con[i];
used_con[i] = null;
cached_pstmt_HashMap.put( new_pstmt.getSql(), new_pstmt );
}
... some other cleaning steps....
...set connection as available...
}

AlexV

> This is crucial because you don't want retained references
> to these objects to allow a 'previous user' to affect anything the next
user
> does. ......

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lincoln Yeoh 2001-06-22 04:13:52 Re: Multiple Indexing, performance impact
Previous Message Tatsuo Ishii 2001-06-22 03:24:22 Re: stuck spin lock with many concurrent users