title: How to lock PostgreSQL database via JDBC?
body: <p>In my Java webapp, each instance is checking on startup if the database is up-to-date via a JDBC connection. If the DB is not up-to-date, it performs an update routine by executing SQL scripts.</p>
  
  <p>I can't control when instances get startet. Therefore, I need to ensure that only a single instance is performing a database update at the same time. Ideally, I would need to lock the complete database, but according to </p>
  
  <p><a href="http://www.postgresql.org/docs/8.4/static/explicit-locking.html" rel="nofollow">http://www.postgresql.org/docs/8.4/static/explicit-locking.html</a></p>
  
  <p>and</p>
  
  <p><a href="http://wiki.postgresql.org/wiki/Lock_database" rel="nofollow">http://wiki.postgresql.org/wiki/Lock_database</a></p>
  
  <p>PostgreSQL doesn't support it (I'm still using version 8.4).</p>
  
  <p>What other options do I have?</p>