import java.sql.*;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
class jdbcCities2 {
  public static void main (String args [])
   throws SQLException {
 // Oracle-Treiber laden
 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 // Verbindung zur Datenbank herstellen
 String url = "jdbc:oracle:thin:@//oracle12c.informatik.uni-goettingen.de:1521/dbis";
 //String url = "jdbc:oracle:thin:@//oracle11.informatik.uni-goettingen.de:1521/dbis";
 Properties props = new Properties();
 try {
 props.load(new FileInputStream("connect.properties"));
 Connection conn = DriverManager.getConnection(url, props);
 // Connection conn = DriverManager.getConnection(url,"may","freiburg0");
 // Anfrage an die Datenbank
 Statement stmt = conn.createStatement();
 ResultSet rset =
   stmt.executeQuery("SELECT Name, Population FROM City");
 while (rset.next()) {
      // Verarbeitung der Ergebnismenge
  String s = rset.getString(1);
  int i = rset.getInt("Population");
  System.out.println (s + " " + i + "\n"); }
  rset.close(); stmt.close(); conn.close();
 } catch(Exception e){e.printStackTrace();}
}}
