code: @Override
      public int doStartTag() throws JspException {
          DataSource ds;
  
          if (dataSource != null) {
              ds = DataSourceUtil.getDataSource(dataSource, pageContext);
          } else {
              if (dataSourceSpecified) {
                  throw new JspException(
                          Resources.getMessage("SQL_DATASOURCE_NULL"));
              }
  
              DataSourceWrapper dsw = new DataSourceWrapper();
              try {
                  // set driver class iff provided by the tag
                  if (driverClassName != null) {
                      dsw.setDriverClassName(driverClassName);
                  }
              }
              catch (Exception e) {
                  throw new JspTagException(
                          Resources.getMessage("DRIVER_INVALID_CLASS",
                                  e.toString()), e);
              }
              dsw.setJdbcURL(jdbcURL);
              dsw.setUserName(userName);
              dsw.setPassword(password);
              ds = (DataSource) dsw;
          }
  
          if (var != null) {
              pageContext.setAttribute(var, ds, scope);
          } else {
              Config.set(pageContext, Config.SQL_DATA_SOURCE, ds, scope);
          }
  
          return SKIP_BODY;
      }
docs: Tag logic