I have a Java application in Tomcat 5.5 that works fine, but it creates
several PostgreSQL processes: <IDLE> in transaction, and they just sit there
forever.  I've updated my library jar files as follows:

iBatis lib file: ibatis-2.3.4.726.jar
JDBC driver: postgresql-8.3-605.jdbc3.jar

The PostgreSQL database server - 8.3.7, using Apache Struts2 -- this is an
action implementation.  I've tried to reduce its code here to a bare minimum
to simplify location of the error.  There are two classes involved, and the
call is to method listOfArtists() in class: ListSwingCatAction.

(1)
public class ListSwingCatAction implements SessionAware
{
   private SqlMapClient sqlMap;
   private SwingCatIBatisDBHandler myDBHandler;
   private Map sessionMap;

   public ListSwingCatAction()
   {
      try
      {
         sqlMap =
SqlMapClientBuilder.buildSqlMapClient(Resources.getResourceAsReader("sqlMaps.xml"));
      }
      catch (Exception e)
      {
         e.printStackTrace();
         throw new RuntimeException ("Error initializing my SwingCat class.
Cause: " + e);
      }

      myDBHandler = new SwingCatIBatisDBHandler(sqlMap);
   }
        
   public String listOfArtists()
   {
      ArrayList artists = myDBHandler.getArtistInfo();
      sessionMap.put("artists", artists);
      return "success";         
   }
}       

(2)
public class SwingCatIBatisDBHandler
{
   private SqlMapClient sqlMap;
   private List list = null;

   public SwingCatIBatisDBHandler(SqlMapClient sqlMap)
   {
      this.sqlMap = sqlMap;
   }

   public ArrayList getArtistInfo()
   {
      ArrayList artists;
      try
      {
         sqlMap.startTransaction();
         //artists is an array of Artists objects -- the list parameter is a
dummy
         artists = (ArrayList) sqlMap.queryForList("getArtistInfo", list );
         sqlMap.commitTransaction();
      }
      catch(SQLException e)
      {
         e.printStackTrace();
         throw new RuntimeException ("Error executing sqlMap query. Cause: "
+ e);
      }
      finally
      {
         try
         {
            sqlMap.endTransaction();
         }
         catch(SQLException e)
         {
            e.printStackTrace();
            throw new RuntimeException ("Error executing sqlMap query.
Cause: " + e);
         }
      }
      return artists;
   }
}

(3) sqlMaps.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd";> 
  
<sqlMapConfig>
  <properties resource="ibatis.properties" />
  <settings
   cacheModelsEnabled="true"
   enhancementEnabled="true"
   lazyLoadingEnabled="true"
   useStatementNamespaces="false" />
  <transactionManager type="JDBC">
    <dataSource type="DBCP">
      <property name="driverClassName" value="${driver}"/>
      <property name="url" value="${url}"/>
      <property name="username" value="${username}"/>
      <property name="password" value="${password}"/>
      <property name="logAbandoned" value="true"/>
      <property name="removeAbandoned" value="true"/>
      <property name="removeAbandonedTimeout" value="1"/>
      <property name="Driver.logUnclosedConnections" value="true"/>
    </dataSource>
  </transactionManager>
  <sqlMap resource="swingCat-sqlMap.xml" />
</sqlMapConfig>

It's probably something very simple, but for the life of me I can't see my
problem.  Any help you can give me would be VERY MUCH apprciated!  Thank
you.

-- 
View this message in context: 
http://www.nabble.com/iBatis---Connections-to-PostgreSQL-Not-Closing-tp25943619p25943619.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


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

Reply via email to