code: protected List<String> getTableNames(final Connection connection) throws SQLException {
          ResultSet resultSet = null;
  
          try {
              final List<String> tables = new ArrayList<String>();
  
              resultSet = connection.getMetaData().getTables(null, null, "%", new String[] { "TABLE" });
  
              while (resultSet.next()) {
                  tables.add(resultSet.getString("TABLE_NAME"));
              }
              return tables;
          } finally {
              if (resultSet != null) {
                  resultSet.close();
              }
          }
  
      }
docs: Returns the names of all tables in the database by using
  {@linkplain DatabaseMetaData}.
  
  @param connection
  the jdbc connection object
  
  @return a {@link List} of all table names
  
  @throws SQLException
  if a database access error occurs