Since I have some time over lunch: 1) I agree with Larry's reply below 2) At the risk of embarrassing myself on this forum, see below for my reply to your comments and questions:
[your-code-sample-was-here] [your-comments-were-here] I've been wrestling with this problem for a long time and right now there are three things about which I wonder: (1) All the code examples I've seen show the sqlMapClient being generated in the same try statement as the actual query. I'm creating it in a separate class and passing it to another class. Could this be a problem? I'm not sure why it would matter, but that is something unique about my situation. >> Usually, your entire application would share a single instance of SqlMapClient. It matters in the sense that it is un-necessary and would, at a minimum, create an entirely new connection pool (see #3 for more) (2) In the above code I use the DataSource obtained from SqlMapClient -- Is there something wrong with doing this? >> Well, probably... and it is un-necessary. Use Larry's version. (i.e. the "normal" way to use the SqlMapClient) (3) Have I somehow mis-configured the connection pool? >> I could be wrong but I still highly suspect that the connections are a result of the connection pool and it seems to me that you're not understanding the purpose of a connection pool. i.e. You're trying to explicitly open a connection with code. The connection pool will usually expand and contract the number of connections to the database based on the load and its configuration (which is why it is called a "pool"). You do not have "direct" control over which connection your iBatis SqlMapClient will use [nor do you probably want that]. I apologize in advance if I am way off base with this response; not my intent to offend, but rather educate. To the masses... in regards to my comment #3, is there an implementation of a "pool" which is not a pool at all but a single connection that someone can use to verify an instance like this? Or maybe configure the "pool" to only have a size of one? Just thinking out loud... I've never had reason to look into something like this but it seems like this question comes up every so often? (i.e. the question of connections opened via iBatis) -----Original Message----- From: Larry Meadors [mailto:[email protected]] Sent: Monday, October 19, 2009 12:56 PM To: [email protected] Subject: Re: iBatis - Connections to PostgreSQL Not Closing This looks to me like you are *way* overcomplicating this. :-) The method should be more like this: public List getArtistInfo(){ return sqlMap.queryForList("getArtistInfo", list); } Unless you have some really crazy wacky stuff going on, there should never be a need for you to deal with connections at that level. Also, what's the purpose of passing in 'list' as the second parameter there? I don't see where it would ever be non-null. Larry --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
