code: private Connection getConnectionFromDataSource(String jndiName,
                                                     Class<? extends JdbcControl.JndiContextFactory> jndiFactory)
              throws SQLException
      {
  
          Connection con = null;
          try {
              JndiContextFactory jf = (JndiContextFactory) jndiFactory.newInstance();
              Context jndiContext = jf.getContext();
              _dataSource = (DataSource) jndiContext.lookup(jndiName);
              con = _dataSource.getConnection();
          } catch (IllegalAccessException iae) {
              throw new ControlException("IllegalAccessException:", iae);
          } catch (InstantiationException ie) {
              throw new ControlException("InstantiationException:", ie);
          } catch (NamingException ne) {
              throw new ControlException("NamingException:", ne);
          }
          return con;
      }
docs: Get a connection from a DataSource.
  
  @param jndiName    Specifed in the subclasse's ConnectionDataSource annotation
  @param jndiFactory Specified in the subclasse's ConnectionDataSource Annotation.
  @return null if a connection cannot be established
  @throws SQLException