private static Connection getConnection(WorkspaceEntry wsEntry) throws DBCleanException
   {
      String dsName = getSourceNameParameter(wsEntry);

      DataSource ds;
      try
      {
         ds = (DataSource)new InitialContext().lookup(dsName);
      }
      catch (NamingException e)
      {
         throw new DBCleanException(e);
      }

      if (ds == null)
      {
         throw new DBCleanException("Data source " + dsName + " not found");
      }

      final DataSource dsF = ds;

      Connection jdbcConn;
      try
      {
         jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
         {
            public Connection run() throws Exception
            {
               return dsF.getConnection();
            }
         });
      }
      catch (SQLException e)
      {
         throw new DBCleanException(e);
      }

      return jdbcConn;
   }
private static Connection getConnection ( WorkspaceEntry wsEntry ) throws DBCleanException { String dsName = getSourceNameParameter ( wsEntry ) ; DataSource ds ; try { ds = ( DataSource ) new InitialContext ( ) . lookup ( dsName ) ; } catch ( NamingException e ) { throw new DBCleanException ( e ) ; } if ( ds == null ) { throw new DBCleanException ( "Data source " + dsName + " not found" ) ; } final DataSource dsF = ds ; Connection jdbcConn ; try { jdbcConn = SecurityHelper . doPrivilegedSQLExceptionAction ( new PrivilegedExceptionAction < Connection > ( ) { public Connection run ( ) throws Exception { return dsF . getConnection ( ) ; } } ) ; } catch ( SQLException e ) { throw new DBCleanException ( e ) ; } return jdbcConn ; }
Opens connection to database underlying a workspace.