Hello, i'm new in tinyos. I would like to inserting data that i've been
received from basestation to database mySQL, so i can access it through
web. Does anyone know how to do it with Oscilloscope application?
According to Mr. Varun Jain answer in
http://www.mail-archive.com/[email protected]/msg27454.html
I'm very confuse about where i have to place this code (Mr. Varun Jain's
answer) :
static String userid="root", password="wireless";
//static String url = "jdbc:mysql://localhost/wsn";
//static String url = "jdbc:mysql://localhost/";
static String url = "jdbc:mysql://localhost/";
//static String dbName = "sms";
static Connection con = null;
static Statement stmt = null;
public static Connection getJDBCConnection()
{
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
//Class.forName("com.mysql.jdbc.Driver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
//con = DriverManager.getConnection(url+dbName,
userid, password);
con = DriverManager.getConnection(url, userid,
password);
}
catch(SQLException ex) {
System.err.println("SQLException: " +
ex.getMessage());
}
return con;
}
try {
Connection con = getJDBCConnection();
}
catch (Exception ex) {
System.err.println("Exception at start: " +
ex.getMessage());
}
try {
if(con!=null)
{
// Get a statement from the connection
Statement stmt = con.createStatement();
String sql;
sql = "SELECT Count(*) as Count FROM
OscilloscopeMsg WHERE source ="+omsg.get_source();
//sql = "SELECT * FROM OscilloscopeMsg";
ResultSet rs = stmt.executeQuery(sql) ;
System.out.println(sql);
rs.close() ;
stmt.executeUpdate(sql);
stmt.close() ;
con.close() ;
}
else {
System.out.println("Could not Get Connection
for oscilloscope message");
}
}
catch (Exception ex) {
System.err.println("Exception: " + ex.getMessage());
}
Where i have to place those codes above in my Oscilloscope.java ??
Please help me :( Sorry for my bad english. Please. Could anyone help me
to out of this?
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help