/****************************************************************/ /* A Simple JDBC Program (Section 5.2) */ /* Chapter 5; Oracle Programming -- A Primer */ /* by R. Sunderraman */ /****************************************************************/ import java.sql.*; import oracle.jdbc.pool.OracleDataSource; import java.io.*; class simple { public static void main (String args []) throws SQLException, IOException { OracleDataSource ods = new OracleDataSource(); // Sets the driver type ods.setDriverType("thin"); // Sets the database server name ods.setServerName("tinman.cs.gsu.edu"); // Sets the database name ods.setDatabaseName("tinman"); // Sets the port number ods.setPortNumber(new Integer(1522)); // Sets the user name ods.setUser("userid"); // Sets the password ods.setPassword("password"); Connection conn=ods.getConnection(); Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("select a from temp"); while (rset.next ()) { System.out.println(rset.getInt(1)); } conn.close(); } //readEntry function -- to read input string static String readEntry(String prompt) { try { StringBuffer buffer = new StringBuffer(); System.out.print(prompt); System.out.flush(); int c = System.in.read(); while(c != '\n' && c != -1) { buffer.append((char)c); c = System.in.read(); } return buffer.toString().trim(); } catch (IOException e) { return ""; } } }