title: Java PreparedStatement and ON DUPLICATE KEY UPDATE: how do I know whether row was inserted or updated?
body: <p>Having following code, how do I know if the execute() method resulted in insert or in update?:</p>
  
  <pre><code>Connection c = DriverManager.getConnection(connectionString);
  
  PreparedStatement st = c.prepareStatement("INSERT INTO `table`(`field1`) VALUES (?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);");
  
  st.setString(1,"some value");
  st.execute();
  </code></pre>
  
  <p>Thanks in advance.</p>