// To compile and run this program on an MCS Department Mac OS X machine: // // Option 1: use eclipse as described in web page linked from the homework. // // Option 2: follow the below instructions: // // (1) Launch a terminal // // (2) Set up the environment based on the shell you use: // // (a) if you are using bash (probably the case) do: // // export DYLD_LIBRARY_PATH=/Users/Shared/instantclient_11_2 // export CLASSPATH=/Users/Shared/instantclient_11_2/ojdbc6.jar:. // // (b) if you are using tcsh: // // setenv DYLD_LIBRARY_PATH /Users/Shared/instantclient_11_2 // setenv CLASSPATH /Users/Shared/instantclient_11_2/ojdbc6.jar:. // // (3) Compile the program (assuming you are in the directory containing it): // // javac ListParties.java // // (4) Run the program: // // java ListParties import java.sql.*; public class ListParties{ public static void main(String[] args){ try{ Class.forName("oracle.jdbc.OracleDriver"); // connect to our server with username "anonymous" and password "anon": Connection myCon = DriverManager.getConnection ("jdbc:oracle:oci:@//thebe.virtual.gac.edu:1521/xe", "anonymous", "anon"); // // You need to put here the code to retrieve the parties' names // and print them out, using the JDBC Connection myCon, as // shown in our textbook. // // I suggest you start with printing one line per candidate // for a U.S. office, showing the office title and party // abbreviation retrieved from the sos.candidates table. // // Then once that works, you can make a fancier version that is // analogous to the PL/SQL procedure I provided as an example, // in which each office is shown on a line with a comma-separated // list of party abbreviations; // } catch(Exception e){ System.err.println(e); System.exit(1); } } }