public static void main(String[] args) throws Exception { String source = null; Vector v = new Vector(); if (args.length > 0) { for (int i = 0; i < args.length; i++) { if (args[i].equals("-comm")) { source = args[++i]; } else { String className = args[i]; try { Class c = Class.forName(className); Object packet = c.newInstance(); Message msg = (Message) packet; if (msg.amType() < 0) { System.err.println(className + " does not have an AM type - ignored"); } else { v.addElement(msg); } } catch (Exception e) { System.err.println(e); } } } } else if (args.length != 0) { usage(); System.exit(1); } MsgReader mr = new MsgReader(source); Enumeration msgs = v.elements(); while (msgs.hasMoreElements()) { Message m = (Message) msgs.nextElement(); mr.addMsgType(m); } mr.start(); }
static void connectDb() { // before: localhost/rsc sqlURL = "jdbc:postgresql://" + sqlURL; // after: "jdbc:postgresql://localhost/rsc"; // "jdbc:postgresql://webbie.berkeley.intel-research.net/rsc" try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException cnfe) { System.out.println("Couldn't find the driver!"); System.out.println("Let's print a stack trace, and exit."); System.exit(1); } Connection connection = null; try { connection = DriverManager.getConnection(sqlURL, sqlUser, sqlPassword); query = connection.createStatement(); } catch (SQLException se) { System.out.println("Couldn't connect: " + se); System.exit(1); } }