ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: iBatis - Connections to PostgreSQL Not Closing
Date Mon, 19 Oct 2009 20:55:08 GMT
OK, you need to refactor that. :-)

The sqlMap should only be created once. I'm not a struts2 user, so I
can't say what the appropriate way to do that is. :-/

If you just want to go ghetto style, you could use a static variable
to hold it and initialize it when the class is loaded...but I'd really
only do that to get a proof of concept working. You should look at the
"struts2" way of doing it, or write a context listener to do it when
your application starts up.

A bit more unsolicited criticism, if you don't mind:

Unless that artist list varies by user (it doesn't look like it does)
putting it in session scope is probably not needed - you could put it
in request scope, cache it in ibatis, and share a single instance of
that list for all users - that would make your application faster and
use less memory.

Using ArrayList as ArrayList is almost never a good idea - unless you
need specific implementation features, just treat it as a List
instead.

Using e.printStackTrace() is really bad - you'd be better off just
saying something like "throw new RuntimeException(e);" because that
way the application won't just silently fail.

Larry

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message