`
Xgw123485
  • 浏览: 89125 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

InformixConnectionPool

阅读更多

package com.huawei.db;

import java.sql.*;

/**
* 分配,回收和管理JDBC连接
*/

public class InformixConnectionPool extends JdbcPool
{
     public InformixConnectionPool
     (
                        String driver, String url,
                        String username, String password,
                        int initialConnections,
                        int maxConnections,
                        int lockwait,
                        boolean waitIfBusy)
          throws SQLException
     {
         super(driver, url, username, password, initialConnections, maxConnections, waitIfBusy);
     }
    
     /*
      *明确地建立一连接。当ConnectionPool初始化时被在前台调用
      *而当ConnectionPool在运行时,该函数在后台线程中被调用
      */
     protected Connection makeNewConnection () throws SQLException
     {
          try
          {
               // Load database driver if not already loaded
               DriverManager.registerDriver((Driver)Class.forName(driver).newInstance());
             
               Connection connection =
               DriverManager.getConnection(url, username, password);
             
               return(connection);
          }
          catch(ClassNotFoundException cnfe)
          {
               // Simplify try/catch blocks of people using this by
               // throwing only one exception type.
               throw new SQLException("Can't find class for driver: " +
                        driver);
          }
          catch(Exception e)
          {
               throw new SQLException("some error getConnection="+e.toString());
          }
     }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics