import java.sql.*; public class Question2 { public static void main(String[] args) { if(args.length < 1) { System.err.println("Usage: Question2 "); System.exit(-1); } Question2 question2 = new Question2(); Connection conn = question2.openConnection(); String studentID = args[0]; try { String query = "{CALL studentTranscript(?)}"; CallableStatement statement = conn.prepareCall(query); statement.setString(1, studentID); ResultSet rs = statement.executeQuery(); while(rs.next()) { String row = rs.getString(1) + ": " + rs.getString(2); System.out.println(row); } } catch (SQLException sqlException) { System.err.println(sqlException.getMessage()); } question2.closeConnection(conn); } private Connection openConnection() { final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot"; final String user = "ishoebot"; final String password = "k7FOLH5B"; Connection conn = null; try { conn = DriverManager.getConnection(url, user, password); } catch (Exception exception) { System.err.printf("Couldn't open a connection: (%s)", exception.getMessage()); } return conn; } private void closeConnection(Connection conn) { try { conn.close(); } catch (Exception exception) { System.err.printf("Couldn't close connection: (%s)", exception.getMessage()); } } }