title: Insert and sort the data at the same time using java
body: <p>This is the sample code which I have written:</p>
  
  <pre><code>String sql =" INSERT INTO "+tablename+" (id,timestamp,type,current_num_workers,target_num_workers) 
  VALUES (?,?,?,?,?)";
  PreparedStatement pstmt=con.prepareStatement(sql);
  
  System.out.println("Fetching records in ascending order...");
  String se="SELECT * FROM " + tablename + " ORDER BY type ASC";
  PreparedStatement pstmt=con.prepareStatement(sql);
  
  pstmt.setString(1, id); 
  pstmt.setString(2, timestamp); 
  pstmt.setString(3, type); 
  pstmt.setString(4, current_num_workers); 
  pstmt.setString(5, target_num_workers);
  pstmt.executeUpdate();
  pstmt.executeUpdate();
  </code></pre>
  
  <p>This is the exception which I am facing:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: A result set was 
  generated for update.
  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:226)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement
  (SQLServerPreparedStatement.java:592)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute
  (SQLServerPreparedStatement.java:508)
  at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:243)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:218)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate
  (SQLServerPreparedStatement.java:461)
  </code></pre>
  
  <p>Help me to resolve this and where I should sort and insert the details at the same time.</p>