// 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 RestockBeer.java // // (4) Run the program providing two integers: // // java RestockBeer beerId additional import java.sql.*; public class RestockBeer{ 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"); PreparedStatement ps = myCon.prepareStatement("call jstudent.restock_beer(?, ?)"); ps.setInt(1, Integer.valueOf(args[0])); ps.setInt(2, Integer.valueOf(args[1])); ps.execute(); } catch(Exception e){ e.printStackTrace(); System.exit(1); } } }