Exemplo n.º 1
0
 public void removeDataSource(String dataSource) {
   JdbcConnectPool pool = findDataSource(dataSource);
   if (pool != null) {
     pool.stopCheckThread();
     pool.destory();
     this.pools.remove(dataSource);
     pool = null;
   }
 }
Exemplo n.º 2
0
 public void destory() {
   if (this.pools != null) {
     Enumeration enum1 = this.pools.keys();
     while (enum1.hasMoreElements()) {
       String s = (String) enum1.nextElement();
       JdbcConnectPool pool = (JdbcConnectPool) this.pools.get(s);
       pool.stopCheckThread();
       pool.destory();
       this.pools.remove(s);
       pool = null;
     }
     this.pools.clear();
   }
 }
Exemplo n.º 3
0
 public synchronized JdbcConnect getJdbcConnect(String dataSource) {
   JdbcConnectPool pool = (JdbcConnectPool) this.pools.get(dataSource.toLowerCase());
   return pool.getJdbcConnect();
 }
Exemplo n.º 4
0
 public void addDataSource(JdbcConnectPool pool) {
   this.pools.put(pool.getDataSource(), pool);
 }
Exemplo n.º 5
0
  public void loadDataSource() {
    JXmlWapper xmlConfig = JXmlWapper.parse(new File(this.configFile));
    int count = xmlConfig.countXmlNodes("dataSource");
    for (int i = 0; i < count; i++) {
      JXmlWapper xmlds = xmlConfig.getXmlNode("dataSource[" + i + "]");
      String dataSource = xmlds.getStringValue("@name");

      String strDescName = xmlds.getStringValue("@desc");
      String driverName = xmlds.getStringValue("@driverName");
      String dbUrl = xmlds.getStringValue("@dbUrl");
      String dbUrlBak = xmlds.getStringValue("@dbUrlBak");
      String userName = xmlds.getStringValue("@userName");
      String passWord = xmlds.getStringValue("@passWord");
      String checkSql = xmlds.getStringValue("@checkSql");
      String serverType = xmlds.getStringValue("@serverType");
      int startNum = xmlds.getIntValue("@startNum", 1);
      int maxNum = xmlds.getIntValue("@maxNum", 5);
      int maxCallNum = xmlds.getIntValue("@maxCallNum", 0);
      int interval = xmlds.getIntValue("@interval", 60);

      JdbcConnectPool pool = new JdbcConnectPool();
      pool.setCheckSql(checkSql);
      pool.setDataSource(dataSource);
      pool.setDbUrl(dbUrl);
      pool.setDbUrlBak(dbUrlBak);
      pool.setDescName(strDescName);
      pool.setDriverName(driverName);
      pool.setInterval(interval);
      pool.setMaxCallNum(maxCallNum);
      pool.setMaxNum(maxNum);
      pool.setPassWord(passWord);
      pool.setServerType(serverType);
      pool.setStartNum(startNum);
      pool.setUserName(userName);
      try {
        pool.startCheckThread();
        pool.createConnects();
      } catch (Exception localException) {
      }
      this.pools.put(dataSource, pool);
    }
  }