龙心紫舒 发表于 2013-1-30 01:31:28

postgreSQL连接池

import javax.servlet.ServletConfig;   
import javax.servlet.ServletException;   
import javax.servlet.http.HttpServlet;   
import org.postgresql.ds.PGPoolingDataSource;   
import com.sun.xml.internal.bind.CycleRecoverable.Context;   
public class postchi extends HttpServlet {   
    public static PGPoolingDataSource pgpool = null;   
    public void destroy() {   
      super.destroy();   
    }   
    public void init() throws ServletException {   
      if(pgpool == null){   
            String DataSourceName=this.getInitParameter("DataSourceName");   
            String ServerName=this.getInitParameter("serverName");   
            String User=this.getInitParameter("User");   
            String Password=this.getInitParameter("password");   
            int MaxConnections=Integer.parseInt(this.getInitParameter("MaxConnections"));   
            String dbInstance=this.getInitParameter("dbInstance");   
          /*System.out.println(User);   
            System.out.println(Password);*/   
            pgpool = new PGPoolingDataSource();   
            pgpool.setDataSourceName(DataSourceName);   
            pgpool.setServerName(ServerName);   
            pgpool.setDatabaseName(dbInstance);   
            pgpool.setUser(User);   
            pgpool.setPassword(Password);   
            pgpool.setMaxConnections(MaxConnections);   
      }   
    }   
}
页: [1]
查看完整版本: postgreSQL连接池