Example #1
0
 public static void removeConnPool(long id) {
   Object o = DBConnPool.getPoolMap().get("_OuterDatabase_" + id + ".");
   if (o == null) {
     return;
   }
   DBConnPoolImpl pool = (DBConnPoolImpl) o;
   pool.clear();
   DBConnPool.getPoolMap().remove("_OuterDatabase_" + id + ".");
 }
Example #2
0
 public void connTest() {
   DBConnConfig dcc = new DBConnConfig();
   dcc.DBName = $V("DBName");
   dcc.DBPassword = $V("Password");
   dcc.DBPort = Integer.parseInt($V("Port"));
   dcc.DBServerAddress = $V("Address");
   dcc.DBType = $V("ServerType");
   dcc.DBUserName = $V("UserName");
   dcc.isLatin1Charset = "Y".equals($V("Latin1Flag"));
   DBConn conn = null;
   try {
     conn = DBConnPoolImpl.createConnection(dcc, false);
     String msg = "测试连接成功";
     DataAccess da = new DataAccess(conn);
     try {
       da.executeOneValue(new QueryBuilder("select 1 from " + $V("TestTable") + " where 1=2"));
     } catch (Exception e) {
       e.printStackTrace();
       msg = msg + ",但表" + $V("TestTable") + "不存在!";
     } finally {
       da.close();
     }
     this.Response.setMessage(msg);
     return;
   } catch (Exception e) {
     e.printStackTrace();
     this.Response.setError("连接到数据库时发生错误:" + e.getMessage());
     return;
   } finally {
     if (conn != null)
       try {
         conn.closeReally();
       } catch (SQLException e) {
         e.printStackTrace();
       }
   }
 }