Question

what I'm currently doing is sending GPS data with a timestamp and other parameters to a remote MSSQL database. At first I've sent it via ksoap2 to a SOAP WebService. Because of the huge overhead I looked for an alternative and implemented the data transmission via JTDS to insert it directly. After I successfully implemented both methods I started comparing them. I've tried to find out which one causes more traffic. I analyzed the network traffic and to my surprise SOAP was cheaper than JTDS. Isn't this weird ? I have sent the same data. I'm using the JTDS 1.2.7 driver. ksoap causes ca. 1.8 kByte traffic and for comparison JTDS causes ca. 2.1 kByte.

Did anyone make the same experience or could tell me what I could change ?

heres the JTDS code. maybe someone can tell me, what is causing the traffic:

try {
   Class.forName("net.sourceforge.jtds.jdbc.Driver");
   String connString = "jdbc:jtds:sqlserver://192.XXX.X.XX/xxxx;encrypt=false;user=XX;password=XX;instance=SQLEXPRESS;";
   conn = DriverManager.getConnection(connString);
} catch (Exception ex){
   ex.printStackTrace();
}

try {
  Log.w("Connection", "open");

  CallableStatement cs = conn.prepareCall("{ call SetGPS(?, ?, ?, ?, ?, ?, ?)}");
  cs.setString(2, latitude);
  cs.setString(3, longitude);
  cs.setInt(4, ID);
  cs.setString(5, timestamp);
  cs.setString(6, IMEI);
  cs.setInt(7, userID);
  cs.registerOutParameter(1, Types.VARCHAR);

  cs.execute();
  String response = cs.getString(1);

  Log.i("GPS Response:", response);

  conn.close();
} catch (Exception ex){
    ex.printStackTrace();
}
Was it helpful?

Solution

Ok I've found out that it's the connection build-up that causes three quarters of the network traffic with JTDS. The actual stored procedure call with the parameters only causes ca. 400 Byte traffic.

So if we do not build up the connection every time we want to send data via JTDS (JDBC), we are much cheaper than with SOAP.

Hope this will someday help someone else ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top