james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Serge Knystautas" <ser...@lokitech.com>
Subject Re: JDBCMailRepository
Date Wed, 25 Jul 2001 13:47:10 GMT
Some of the connection poolers I'm familiar with (the ones that pretend to
be a JDBC driver) treat close() as returning the connection to the pool.
Then this code would work fine (as it does in my installation).

We shouldn't pass an actual connection because then that connection is being
wasted by a message that might never need it (for the duration of its
existence).  The way it works now let's the stream only use a connection
when and while it needs it.

Serge Knystautas
Loki Technologies
http://www.lokitech.com/
----- Original Message -----
From: "Oki DZ" <okidz@pindad.com>
To: <james-dev@jakarta.apache.org>
Sent: Tuesday, July 24, 2001 10:49 PM
Subject: JDBCMailRepository


> Hi,
>
> As I understand it, MimeMessageJDBCSource creates a JDBC connection and
> then returns an input stream that is to be used in MimeMessageWrapper (the
> class that retrieves the bytes from the db server via the input stream).
> The JDBC connection in MimeMessageJDBCSource couldn't be closed before
> MimeMessageWrapper reads the input stream; if it were, then no byte could
> be read from the stream. Problem is, if the JDBC connection never be
> closed, the server will run out of connection.
>
> public MailImpl retrieve(String key) {
> //...
>     MimeMessageJDBCSource source = new MimeMessageJDBCSource(this,key);
>     MimeMessageWrapper message = new MimeMessageWrapper(source);
>     mc.setMessage(message);
>     rsMessage.close();
>     retrieveMessage.close();
>     conn.close();
>     return mc;
>
> I think it would be nicer to put MimeMessageWrapper inside the
> MimeMessageJDBCSource, so that you wouldn't have problem about when to
> close the JDBC connection; and a getMessage() method in
> MimeMessageJDBCSource would be sufficient.
>
> But addding java.sql.Connection as a parameter to MimeMessageJDBCSource's
> constructor would be easier, though.
>
> BTW, you have conn = repository.getConnection() in MimeMessageJDBCSource's
> getInputStream(), but getConnection() is protected in JDBCMailRepository.
>
> Oki
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message