title: Detecting when inserting duplicate rows in Java/MyBATIS
body: <p>I am currently using MyBATIS in my project.</p>
  
  <p>I sometimes need to run an INSERT query but ignore if the row I'm trying to insert is already present on DB, but instead handle other SQL errors.</p>
  
  <p>How can I find that the SQLException is related to primary key violation?</p>
  
  <p>Something like</p>
  
  <pre><code>try {
      sqlMap.insert(query, params);
  } catch (DuplicateKeyException ex) {
      //Do nothing, it's OK for mew
  } catch (SQLException ex) {
      throw ex;
  }
  </code></pre>
  
  <p>I suppose that specific exception doesn't really exist...</p>