docs: public void fillJCDFromDataSource(JdbcConnectionDescriptor jcd, DataSource dataSource, String username, String password) throws MetadataException
      {
          String           realUsername = (jcd.getUserName() != null ? jcd.getUserName() : username);
          String           realPassword = (jcd.getPassWord() != null ? jcd.getPassWord() : password);
          Connection       connection   = null;
          DatabaseMetaData metadata     = null;
  
          try
          {
              // we have to open a connection to be able to retrieve metadata
              if (realUsername != null)
              {
                  connection = dataSource.getConnection(realUsername, realPassword);
              }
              else
              {
                  connection = dataSource.getConnection();
              }
  
              metadata = connection.getMetaData();
          }
          catch (Throwable t)
          {
              if (connection != null)
              {
                  try
                  {
                      connection.close();
                  }
                  catch (SQLException ex)
                  {}
              }
              throw new MetadataException("Could not get the metadata from the given datasource", t);
          }
  
          try
          {
              HashMap urlComponents = parseConnectionUrl(metadata.getURL());
      
              if (urlComponents.containsKey(PROPERTY_DBALIAS))
              {
                  jcd.setProtocol((String)urlComponents.get(PROPERTY_PROTOCOL));
                  jcd.setSubProtocol((String)urlComponents.get(PROPERTY_SUBPROTOCOL));
                  jcd.setDbAlias((String)urlComponents.get(PROPERTY_DBALIAS));
                  if (jdbcSubProtocolToPlatform.containsKey(jcd.getSubProtocol()))
                  {
                      // TODO: We might be able to use this: metadata.getDatabaseProductName();
                      jcd.setDbms((String)jdbcSubProtocolToPlatform.get(jcd.getSubProtocol()));
                  }
              }
          }
          catch (Throwable t)
          {
              try
              {
                  connection.close();
              }
              catch (SQLException ex)
              {}
              throw new MetadataException("Could not get the metadata from the given datasource", t);
          }
          try
          {
              // this will only work with JDK >= 1.4 and only with some jdbc drivers
              Integer majorVersion = (Integer)PropertyUtils.getProperty(metadata, "JDBCMajorVersion");
              Integer minorVersion = (Integer)PropertyUtils.getProperty(metadata, "JDBCMinorVersion");
  
              jcd.setJdbcLevel(Double.parseDouble(majorVersion.toString()+"."+minorVersion.toString()));
          }
          catch (Throwable t)
          {
              // otherwise we're assuming JDBC 2.0 compliance
              jcd.setJdbcLevel(2.0);
          }
          try
          {
              connection.close();
          }
          catch (SQLException ex)
          {}
      }