Update of /cvsroot/firebug/firebug/project/java/src/org/firebug
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19340/java/src/org/firebug
Modified Files:
ListenFB.java
Log Message:
java listening code now supports creating
a database from the command line.
Index: ListenFB.java
===================================================================
RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/ListenFB.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** ListenFB.java 9 Aug 2004 19:47:37 -0000 1.23
--- ListenFB.java 28 Sep 2004 23:59:00 -0000 1.24
***************
*** 29,32 ****
--- 29,33 ----
import javax.comm.*;
import java.sql.*;
+ import org.firebug.database.MysqlDBHandler;
***************
*** 61,64 ****
--- 62,75 ----
+ static String location_table = "CREATE TABLE location (mote_id SMALLINT, gps_hours SMALLINT, gps_minutes SMALLINT, gps_seconds FLOAT, lat_deg SMALLINT,"
+ + "lat_dec_min FLOAT, long_deg SMALLINT, long_dec_min FLOAT, nsew SMALLINT, numsats SMALLINT)";
+ static String current_table = "CREATE TABLE current (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp FLOAT, rel_hum FLOAT, baro_pres FLOAT, lux FLOAT)";
+ static String cumulative_table = "CREATE TABLE cumulative (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp FLOAT, rel_hum FLOAT, baro_pres FLOAT, lux FLOAT)";
+ static String range_table = "CREATE TABLE range (mote_id SMALLINT, time TIMESTAMP, count INTEGER, rssi INTEGER, voltage FLOAT)";
+
+
+
+
+
private FireLogger firelogger;
private RangeLogger rangelogger;
***************
*** 70,74 ****
new dispatch(129,rangelogger),
new dispatch(0,null)
! };
/** Use this interface when changing the output
--- 81,85 ----
new dispatch(129,rangelogger),
new dispatch(0,null)
! };
/** Use this interface when changing the output
***************
*** 121,125 ****
return gpslogger;
} else {
! return xbowlogger;
}
}
--- 132,136 ----
return gpslogger;
} else {
! return xbowlogger;
}
}
***************
*** 184,191 ****
static int get_xbow_packet_id(byte [] packet) {
! int packet_id = (int)(packet[6]&0xFF);
! if (packet_id == 1) return 137;
! if (packet_id == 2) return 138;
! return 0;
}
--- 195,202 ----
static int get_xbow_packet_id(byte [] packet) {
! int packet_id = (int)(packet[6]&0xFF);
! if (packet_id == 1) return 137;
! if (packet_id == 2) return 138;
! return 0;
}
***************
*** 221,225 ****
PacketPrinter printer = GetPrinter(am_type);
if (printer != null) {
! printer.print(packet);
}
}
--- 232,236 ----
PacketPrinter printer = GetPrinter(am_type);
if (printer != null) {
! printer.print(packet);
}
}
***************
*** 247,256 ****
! if (args.length != 3) {
! printUsage();
! }
! dbname = args[1];
if (args[args.length - 1].charAt(0) == '-') {
--- 258,329 ----
! if (args.length != 3) {
! printUsage();
! }
! dbname = args[1];
!
! Connection connection;
!
! /* Put a check in here to make the db exists, and if
! * if doesn't exist, create it.
! */
! String URL2 = "jdbc:mysql://"
! + "localhost"
! + ":"
! + "3306"
! + "/"
! //+ dbname
! + "?user="
! + "root"
! + "&password="
! + "";
! try {
! // The newInstance() call is a work around for some
! // broken Java implementations
! Class.forName("org.gjt.mm.mysql.Driver").newInstance();
! }
! catch (Exception E) {
! System.err.println("Unable to load driver.");
! E.printStackTrace();
! }
!
! try {
! connection = DriverManager.getConnection(URL2, "root", "");
! System.out.println("Connection with null database.");
! Statement stmt = connection.createStatement();
! //try {
! stmt.executeUpdate("create database " + dbname);
! stmt.executeUpdate("use " + dbname);
! stmt.executeUpdate(location_table);
! stmt.executeUpdate(current_table);
! stmt.executeUpdate(cumulative_table);
! stmt.executeUpdate(range_table);
!
! //} catch (Exception e) {
! //e.printStackTrace();
! //}
! } catch (SQLException e) {
! System.out.println("We are not connecting here...");
! int error = e.getErrorCode();
! e.printStackTrace();
!
! if (error == 1049) {
! System.out.println("1049: Unknown database specified");
! }
!
! if (error == 1007) {
! System.out.println("1007: Database exists...");
! }
!
!
! }
!
! /*
! catch (Exception e) {
! e.printStackTrace();
! }
! */
if (args[args.length - 1].charAt(0) == '-') {
***************
*** 284,288 ****
listener.read();
} catch (Exception e) {
! e.printStackTrace();
}
}
--- 357,361 ----
listener.read();
} catch (Exception e) {
! e.printStackTrace();
}
}
|