/* Java to access CS Oracle database directly Replace and below with suitable strings Original author: R Bland Adapted by Simon Jones */ import java.sql.*; public class CSOracleDirect { public static void main(String args[]) { String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@oracle.cs.stir.ac.uk:1521:cs" ; // The last part is the name of a database Connection con; ResultSet rs ; Statement stmt ; // try { Class.forName(driver) ; } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: ") ; System.err.println(e.getMessage()) ; } try { con = DriverManager.getConnection(url, , ); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT DISTINCT Season, Title FROM sbj.Panto"); ResultSetMetaData rsmd = rs.getMetaData(); int numberOfColumns = rsmd.getColumnCount(); int rowCount = 0; while (rs.next()) { System.out.println("Row " + (++rowCount) + ": ") ; for (int i = 1; i <= numberOfColumns; i++) { System.out.print(" Column " + i + ": ") ; System.out.print(rsmd.getColumnLabel(i) + ": ") ; // or could use columnName System.out.println(rs.getString(i)) ; }} con.close() ; } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()) ; }} }