import java.io.*;
import java.net.*;
import java.nio.*;

class TCPServer {
  public static void main(String argv[]) throws Exception
  {
    String clientSentence;
    String capitalizedSentence;
    String objectId;
    String temperature;
    ServerSocket TCPSocket = new ServerSocket(6789);
    while(true)
    {
      Socket connectionSocket = TCPSocket.accept();
      BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
      clientSentence = inFromClient.readLine();

      ByteBuffer buffer = ByteBuffer.wrap(clientSentence.getBytes());
      buffer.order(ByteOrder.LITTLE_ENDIAN);
      objectId = new String(buffer.get(new byte[], 0, 16), Charset.forName("UTF-8"));
      temperature = new String(buffer.get(new byte[], 17, 2), Charset.forName("UTF-8"));

    }
  }
}
@@ -48,16 +48,225 @@
 a.nio.*;
+%0Aimport java.util.Date;%0Aimport com.mongodb.BasicDBObject;%0Aimport com.mongodb.DB;%0Aimport com.mongodb.DBCollection;%0Aimport com.mongodb.DBCursor;%0Aimport com.mongodb.MongoClient;%0Aimport com.mongodb.MongoException;
 %0A%0Aclass 
@@ -1020,23 +1020,397 @@
 %22UTF-8%22));%0A%0A
+      MongoClient mongo = new MongoClient(%22localhost%22, 27017);%0A      DB db = mongo.getDB(%22testdb%22);%0A      DBCollection table = db.getCollection(%22status_log%22);%0A      BasicDBObject document = new BasicDBObject();%0A      document.put(%22device%22, objectId);%0A      document.put(%22temperature%22, temperature);%0A      document.put(%22saved_at%22, new Date());%0A      table.insert(document);%0A%0A
     %7D%0A  %7D%0A%7D

Add MongoDB support