Example #1
0
 private void SetDataSource() {
   if (sf.useDummyData) {
     sf.dataSource = new DummySource(sf);
   } else if (sf.bSourceSim) {
     try {
       sf.dataSource =
           (DataSource)
               (Class.forName("net.tinyos.sf.old.nido.SimNetworkDataSource").newInstance());
       sf.dataSource.setSerialForward(sf);
     } catch (Exception e) {
       System.err.println("Cannot instantiate SimNetworkDataSource - did you compile it? " + e);
       return;
     }
   } else if (sf.bNidoSerialData) {
     // Doing it this way to avoid having to compile NidoSerialDataSource
     // which requires all of the TOSSIM event classes
     // sf.dataSource = new NidoSerialDataSource(sf);
     try {
       sf.dataSource =
           (DataSource)
               (Class.forName("net.tinyos.sf.old.nido.NidoSerialDataSource").newInstance());
       sf.dataSource.setSerialForward(sf);
     } catch (Exception e) {
       System.err.println("Cannot instantiate NidoSerialDataSource - did you compile it? " + e);
       return;
     }
   } else if (sf.bSourceDB) {
     sf.dataSource = new DBSource(sf);
   } else if (sf.bQueuedSerial) {
     System.out.println("USING QUEUED SERIAL SOURCE");
     sf.dataSource = new QueuedSerialSource(sf);
   } else if (sf.commPort_is_socket) {
     sf.dataSource = new NetworkSource(sf);
   } else {
     sf.dataSource = new SerialSource(sf);
   }
 }
Example #2
0
 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);
   }
 }