【poolman&struts】关于returnConnection

04-04-23 wxuxu
连接池是用poolman实现,采用struts框架

package struts.xcw;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.sql.*;
import java.io.*;
import com.codestudio.util.*;

public class ViewAllAction extends Action
{
	public ActionForward execute(ActionMapping mapping,
				 ActionForm form,
				 HttpServletRequest request,
				 HttpServletResponse response)
	{


		SQLManager manager = null;
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		try
		{
			manager = SQLManager.getInstance();
			conn = manager.requestConnection("zqf");
			stmt = conn.createStatement();

			String sql="select * from xcw_user_info";
			rs = stmt.executeQuery(sql);		
			
		}
		catch(Exception e)
		{
			System.out.println("heheehheheheehhehe");
			
		}
  	////////////manager.returnConnection("zqf", conn);
		
		request.setAttribute("result",rs);
		return (mapping.findForward("success"));


	}
	}

<p>

如果没有manager.returnConnection("zqf", conn);则没问题,达到预定目标

但有了之后出错:object has been closed .

看了前面一篇大家的讨论,还是不能自己解决这个问题,

所以请各位指点指点!

猜你喜欢