import java.sql.*;
import java.io.FileInputStream;
import java.util.Properties;
class JdbcSelectObj {
  public static void main (String args []) throws Exception {
   Connection conn = getConn();  // unten rausgescrollt
   Statement stmt = conn.createStatement();
   ResultSet rset = stmt.executeQuery("SELECT * FROM " + args[0]);
   ResultSetMetaData rsmd = rset.getMetaData();
   int numCols = rsmd.getColumnCount();
   for(int i=1; i<=numCols; i++)  System.out.print(rsmd.getColumnType(i) + " ");
   System.out.println();
   for(int i=1; i<=numCols; i++)  System.out.print(rsmd.getColumnTypeName(i) + " ");
   System.out.println();
   // continue next slide





   while (rset.next()) {
    for(int i=1; i<=numCols; i++) {
     Object value = rset.getObject(i);
     // System.out.println(rsmd.getColumnType(i));
     if (rset.wasNull()) System.out.print("null  ");
     else if (rsmd.getColumnType(i) == java.sql.Types.STRUCT)
     { java.sql.Struct s = (java.sql.Struct)value;
       System.out.print(s.getSQLTypeName() + "( ");
       Object[] attrs = s.getAttributes();
       // attributes
       for (int j = 0; j < attrs.length; j++) System.out.print(attrs[j] + " ");
       System.out.print(")");
     }
     // This also covers Java instances (uses their toString())
     else System.out.print(value + "  ");
   }
   System.out.println();  }
   rset.close(); stmt.close(); conn.close();  }
 private static Connection getConn() throws Exception {
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   Properties props = new Properties();
   props.load(new FileInputStream("conn.props"));
   Connection conn = DriverManager.getConnection(props.getProperty("url"), props);
   return conn;  }}
