Note that there are some explanatory texts on larger screens.

plurals
  1. POBuffereader to inputstream still having corruption
    text
    copied!<p>We have java socket connection application which receives data from gps devices. The problem now at times we received corrupted data and checked on the device logs everything is fine. First BufferedReader was used and suspected to be the culprit. The we moved to inpustream also still having problem. The corruption is at random and not fixed interval. Below is the snippet of codes.</p> <pre><code>public void run() { String completeMessage=""; //BufferedReader readerBuffer = null; InputStream is = null; BufferedWriter writeBuffer = null; try { //readerBuffer = new BufferedReader(new InputStreamReader(sockConn1.getInputStream())); is = sockConn1.getInputStream(); writeBuffer = new BufferedWriter(new OutputStreamWriter(sockConn1.getOutputStream())); int readChar=0; sockConn1.setSoTimeout(120000); //dbConnection = connectionPool.getConnection(); //dbConnection.setAutoCommit(false); int readChar while ((readChar=is.read()) != -1) { System.out.println("Char value: "+(char)readChar) ; if (readChar == '*') { try { //writeBuffer.write("@@\r\n\r\n"); //writeBuffer.flush(); //db processing dbConnection.commit(); } catch (SQLException ex){ ex.printStackTrace(); try{ dbConnection.rollback(); } catch (Exception rollback){ rollback.printStackTrace(); } } catch (Exception e){ e.printStackTrace(System.out); try{ dbConnection.rollback(); } catch (Exception rollback){ rollback.printStackTrace(System.out); } } finally{ try{ if ( dbStmt != null ){ dbStmt.close(); } } catch(SQLException ex){ ex.printStackTrace(System.out); } } completeMessage=""; } } } catch (SocketTimeoutException ex){ ex.printStackTrace(); } catch (IOException ex){ ex.printStackTrace(); } catch (Exception ex){ ex.printStackTrace(); } finally{ try{ if ( dbConnection != null ){ dbConnection.close(); } } catch(SQLException ex){ ex.printStackTrace(); } try{ if ( writeBuffer != null ){ writeBuffer.close(); } } catch(IOException ex){ ex.printStackTrace(System.out); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload