コード例 #1
0
 public Connection connect(String url, Properties info) throws SQLException {
   if (ConnectionLogger.isInfoEnabled()) {
     StringBuffer sb = new StringBuffer();
     sb.append("connect to URL ").append(url).append(" with properties: ").append(info.toString());
     ConnectionLogger.info(sb.toString());
   }
   if (!acceptsURL(url)) throw new SQLException("Invalid URL" + url);
   url = "jdbc:" + url.substring(urlPrefix.length());
   StringTokenizer ts = new StringTokenizer(url, ":/;=&?", false);
   String targetDriver = null;
   while (ts.hasMoreTokens()) {
     String s = ts.nextToken();
     logger.debug("s = " + s);
     if (targetDriverParameter.equals(s) && ts.hasMoreTokens()) {
       targetDriver = ts.nextToken();
       break;
     }
   }
   if (targetDriver == null)
     throw new SQLException("Can't find targetDriver parameter in URL: " + url);
   url =
       url.substring(0, url.length() - targetDriver.length() - targetDriverParameter.length() - 2);
   try {
     Class.forName(targetDriver);
     return ConnectionLoggingProxy.wrap(DriverManager.getConnection(url, info));
   } catch (Exception e) {
     ConnectionLogger.error(e.getMessage(), e);
     throw new SQLException(e.getMessage());
   }
 }
コード例 #2
0
 static {
   try {
     DriverManager.registerDriver(new DriverLoggingProxy());
   } catch (Exception exception) {
     ConnectionLogger.error(exception.getMessage(), exception);
   }
 }