title: select "for update" with JDBC?
body: <p>I want to create a <code>for update</code> select statement in Java using JDBC, but not sure how it would be done.</p>
  
  <p>If you are unfamiliar with for update you can read about it here
  <a href="https://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE" rel="nofollow noreferrer">https://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE</a></p>
  
  <p>For example, I have the following select statements</p>
  
  <p>My select statement</p>
  
  <pre><code>select email from email_accounts where already_linked = false order by random() limit 1
  </code></pre>
  
  <p>My update statement</p>
  
  <pre><code>UPDATE email_accounts set already_linked = true, account_link_timestamp = now() where email = ?
  </code></pre>
  
  <p>How would this be done in Java using JDBC while using <code>for update</code>?</p>