예제 #1
0
 @Override
 protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info)
     throws SQLException {
   try {
     closeLock.readLock().lock();
     checkClosed();
     ConnectionInfo connInfo = ConnectionInfo.create(url);
     QueryServices services = getQueryServices();
     ConnectionInfo normalizedConnInfo = connInfo.normalize(services.getProps());
     ConnectionQueryServices connectionQueryServices =
         connectionQueryServicesMap.get(normalizedConnInfo);
     if (connectionQueryServices == null) {
       if (normalizedConnInfo.isConnectionless()) {
         connectionQueryServices =
             new ConnectionlessQueryServicesImpl(services, normalizedConnInfo);
       } else {
         connectionQueryServices =
             new ConnectionQueryServicesImpl(services, normalizedConnInfo, info);
       }
       ConnectionQueryServices prevValue =
           connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
       if (prevValue != null) {
         connectionQueryServices = prevValue;
       }
     }
     boolean success = false;
     SQLException sqlE = null;
     try {
       connectionQueryServices.init(url, info);
       success = true;
     } catch (SQLException e) {
       sqlE = e;
     } finally {
       if (!success) {
         try {
           connectionQueryServices.close();
         } catch (SQLException e) {
           if (sqlE == null) {
             sqlE = e;
           } else {
             sqlE.setNextException(e);
           }
         } finally {
           // Remove from map, as initialization failed
           connectionQueryServicesMap.remove(normalizedConnInfo);
           if (sqlE != null) {
             throw sqlE;
           }
         }
       }
     }
     return connectionQueryServices;
   } finally {
     closeLock.readLock().unlock();
   }
 }
예제 #2
0
 @Override
 protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info)
     throws SQLException {
   ConnectionInfo connInfo = ConnectionInfo.create(url);
   ConnectionInfo normalizedConnInfo = connInfo.normalize(getQueryServices().getProps());
   ConnectionQueryServices connectionQueryServices =
       connectionQueryServicesMap.get(normalizedConnInfo);
   if (connectionQueryServices == null) {
     if (normalizedConnInfo.isConnectionless()) {
       connectionQueryServices = new ConnectionlessQueryServicesImpl(getQueryServices());
     } else {
       connectionQueryServices =
           new ConnectionQueryServicesImpl(getQueryServices(), normalizedConnInfo);
     }
     connectionQueryServices.init(url, info);
     ConnectionQueryServices prevValue =
         connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
     if (prevValue != null) {
       connectionQueryServices = prevValue;
     }
   }
   return connectionQueryServices;
 }