关于连接池的应该很多,你可以查下这里的FAQ试一试!

解决方案 »

  1.   

    poolman的主页说它已经不再支持了,而且我用过有很多bug,用Apache的连接池,挺好用的。
    我写了一个测试用的调用类,你可以参考一下。
    ==============================================================================
    需要的jar包都在apache的common下:
    commons-dbcp-1.1.jar
    commons-pool-1.1.jar
    commons-collections.jar===============================================================================
    import org.apache.commons.dbcp.BasicDataSource;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.*;public class ConnectionPool {  private static BasicDataSource bds = new BasicDataSource();  private final static String url = "jdbc:oracle:thin:@192.168.1.251:1521:test";
      private final static String user = "test";
      private final static String password = "test";
      private final static String driver = "oracle.jdbc.driver.OracleDriver";
      static{
        bds.setUrl(url);
        bds.setUsername(user);
        bds.setPassword(password);
        bds.setDriverClassName(driver);
        bds.setMaxActive(5);
        bds.setMaxIdle(5);
        bds.setMinIdle(2);
      }  private ConnectionPool() {
      }  public static Connection getConnection()
          throws SQLException
      {
        long btime = System.currentTimeMillis();
        Connection conn = bds.getConnection();
        System.out.println("Connection type: " + conn.getClass().getName());
        System.out.println("Connection address: "+conn);
        long tt = System.currentTimeMillis() - btime;
        System.out.println("get Connection consume time is "+tt
                  + " ms! connection address:"+conn);
        return conn;  }  public static void main(String[] args) {
        Connection conn = null;
        try {
          conn = ConnectionPool.getConnection();
          conn.close();
          conn = ConnectionPool.getConnection();
          String sql = "select * from userpassport";
          Statement stem = conn.createStatement();
          ResultSet rs = stem.executeQuery(sql);
          while(rs.next())
          {
            System.out.println(rs.getString("name"));
          }
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally{
            try {
              conn.close();
            }
            catch (SQLException e) {
              e.printStackTrace();
            }
        }
      }}
      

  2.   

    高分求助:谁用过poolman??~~~~~见者有分~~~~~谢谢!
    呵呵~我看见了,?!?!?!
      

  3.   

    现面是一个在weblogic下的连接池应用的测试页面。
    如果你配置好了话,可以试一试!<%@page contentType="text/html;CHARSET=GBK" %>
    <%@page import="java.sql.*,java.util.*,javax.naming.*,javax.sql.*" %><HTML>
    <HEAD>
    <TITLE>
    data connection</TITLE>
    </HEAD>
    <BODY><%
        Context ctx = null; 
        Hashtable ht = new Hashtable();  
        ht.put(Context.INITIAL_CONTEXT_FACTORY, 
                   "weblogic.jndi.WLInitialContextFactory"); 
        ht.put(Context.PROVIDER_URL, "t3://localhost:80");    System.out.println("ok1");
        try {    
            ctx = new InitialContext(ht);   
                System.out.println("ok2");         
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("你的JNDI Name");
            
            System.out.println("ok3");
            java.sql.Connection conn = ds.getConnection();


            // You can now use the conn object to create Statements and retrieve result sets:

             Statement stmt = conn.createStatement();
             ResultSet rs =stmt.executeQuery("select * from dual ");
             
             out.println("&sup2;é&Ntilde;&macr;&frac12;á&sup1;&ucirc;:<br>");
             while (rs.next())
             {
                out.println(rs.getString(1)+"<br>");
             }

             // Close the statement and connection objects when you are finished:


             stmt.close(); 
             conn.close();
             }
             catch (Exception e) 
             {   
               e.printStackTrace();
             } 
             finally 
             { 
                try 
                {
                     ctx.close();
                }
                catch (Exception e)
                {      // a failure occurred    
                     e.printStackTrace();
                }  
             }    
    %>           
    </BODY>
    </HTML>
      

  4.   

    Apache也是单个的连接池程序???
    还是像tomcat weblogic一样的服务器???
      

  5.   

    to  kitty009(刁蛮公主):
    Tomcat的连接池用的就是Apache的。因为Tomcat就是Apache的子项目:->
    Apache的连接池是他的一个公共项目,就是commons下的一个包,只是还用到了commons下的其他两个包。
      

  6.   

    PoolMan在多线程争用时可能会出现线程死锁的问题!!!楼主可以看一下近几个月的程序员杂志具体哪一期忘了^)^