code: private Set<String> populateTableNames(String url) throws SQLException
     {
        Set<String> tableNames = new HashSet<String>();
        Connection connection = null;
        ResultSet rs = null;
  
        try
        {
           connection = DriverManager.getConnection(url);
           DatabaseMetaData dmd = connection.getMetaData();
           rs = dmd.getTables(null, null, null, null);
           while (rs.next())
           {
              tableNames.add(rs.getString("TABLE_NAME").toUpperCase());
           }
        }
  
        finally
        {
           if (rs != null)
           {
              rs.close();
           }
  
           if (connection != null)
           {
              connection.close();
           }
        }
  
        return tableNames;
     }
docs: Open a database and build a set of table names.
  
  @param url database URL
  @return set containing table names