日期:2014-05-20  浏览次数:20854 次

使用proxool-0.9.0RC2连接池内存泄漏问题?
程序中使用proxool-0.9.0RC2.连接池,但导致了内存泄漏,代码如下:
package   com.mypackage;

import   java.io.File;
//import   org.apache.log4j.Category;
//import   .......(省略)

public   class   ProxoolTest   extends   Thread   {
private   Connection   conn   =   null;

public   ProxoolTest()   {
this.conn   =   DBConnectionManage.getConnection();
this.start();
}

public   void   run()   {
this.uploadCSV();
DBConnectionManage.closeConnection(conn);
}

/**
  *   上传CSV文件
  */
private   void   uploadCSV()   {
StringBuffer   sqlQueryUsage   =   new   StringBuffer();
sqlQueryUsage.append( "select   *   from   tableName ");

Statement   stmt   =   null;
ResultSet   rst   =   null;

try   {
stmt   =   this.conn.createStatement();
rst   =   stmt.executeQuery(sqlQueryUsage.toString());

while   (rst.next())   {
String   subId   =   rst.getString( "SUBSCRIBER_ID ");

if   (this.isUpload(subId,   row))   {
//   将数据写入文件
}
}
}   catch   (Exception   e)   {
e.printStackTrace();
}   finally   {
try   {
if   (rst   !=   null)
rst.close();
if   (stmt   !=   null)
stmt.close();

}   catch   (Exception   e)   {
System.err.println( "System   Error ");
}
}
}

/**
  *   是否满足上传条件
  *  
  *   @param   row
  *                         一条上传数据
  *   @return   boolean   true:满足;false:不满足
  */
private   boolean   isUpload(String   subId)   {
StringBuffer   sql   =   new   StringBuffer();
sql
.append( "SELECT   a.subscriber_id,   "
+   "quota_usage1   -   quota_limit1   quota1,   quota_usage2   -   quota_limit2   quota2,   "
+   "quota_usage3   -   quota_limit3   quota3,   quota_usage4   -   quota_limit4   quota4     "
+   "FROM   qm_subscriber_quota_usage   a,   qm_subscriber_quota_limit   b   "
+   "WHERE   a.subscriber_id   =   ' "   +   subId
+   " '   AND   a.subscriber_id   =   b.subscriber_id   ");

Statement   stmt   =   null;
ResultSet   rst   =   null;

try   {
stmt   =   conn.createStatement();
rst   =   stmt.executeQuery(sql.toString());

if   (rst.next())   {
for   (int   i   =   1;   i   <=   4;   i++)   {
if   (Long.parseLong(rst.getString( "QUOTA "   +   i))   > =   0)
return   true;
}
}
}   catch   (Exception   e)   {

}   finally   {
try   {
if   (rst   !=   null)   {
rst.close();