import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ListSchemas
{
  public ListSchemas(Connection connection)
  {
    DatabaseMetaData databaseMetaData = null;
    ResultSet schemaNames = null;
    try
    {
      databaseMetaData = connection.getMetaData();
      schemaNames = databaseMetaData.getSchemas();
      while (schemaNames.next())
      {
        System.out.println
        (
          "Schema: " + 
          schemaNames.getString("table_schem")
        );
      }
      schemaNames.close();
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
  }
}

