package jdbc;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.logicalcobwebs.proxool.*;
import java.sql.DriverManager;
/**
* 通过组件连接Oracle数据库
*/

import org.logicalcobwebs.proxool.ProxoolDriver;
public class JDBCData
{
    
  public static void main(String[] args)
  {
    // TODO Auto-generated method stub
    try
    {
      //加载启动
      Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
      //设置属性,连接数
      Properties info = new Properties();
      info.setProperty("proxool.maximum-connection-count", "10");
      info.setProperty("proxool.house-keeping-test-sql", "select CURRENT_DATA");
      //用户名和密码
      info.setProperty("user", "SYSTEM");
      info.setProperty("password", "password");
      String alias = "test";
      //加载Oracle的启动和URL
      String driverClass = "oracle.jdbc.driver.OracleDriver";
      String deiverURL = "jdbc:oracle:thin:@localhost:1521:orcl";
      String url = "proxool." + alias + ":" + driverClass + ":" +deiverURL;
      //通过组件的方式注册连接
      ProxoolFacade.registerConnectionPool(url,info);
        
      Connection con = DriverManager.getConnection(url);
      Statement st = con.createStatement();
      ResultSet rs = st.executeQuery("select * from student");
      while(rs.next())
      {
        System.out.println(rs.getString(1));
        System.out.println(rs.getString(2));
        System.out.println(rs.getString(3));
      }
        
    }
    catch (ClassNotFoundException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    catch (ProxoolException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    catch (SQLException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
}
此连接方式需要以下库文件: