title: Tomcat Error: Embedded H2 DB Read-Only
body: <p>I am getting the following error in my tomcat logs when trying to start an app that uses an <code>embedded h2.db</code> file:</p>
  
  <pre><code>Caused by: org.h2.jdbc.JdbcSQLException: The database is read only**; SQL statement:&lt;br&gt;
  UPDATE DATABASECHANGELOGLOCK SET LOCKED = TRUE, LOCKEDBY = '192.168.122.1 (192.168.122.1)', LOCKGRANTED = '2017-10-19 17:06:08.499' WHERE ID = 1 AND LOCKED = FALSE [90097-175]&lt;br&gt;
          at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
          at org.h2.message.DbException.get(DbException.java:172)
          at org.h2.message.DbException.get(DbException.java:149)
          at org.h2.message.DbException.get(DbException.java:138)
          at org.h2.engine.Database.checkWritingAllowed(Database.java:1784)
          at org.h2.table.Table.checkWritingAllowed(Table.java:1082)
          at org.h2.engine.User.hasRight(User.java:114)
          at org.h2.engine.User.checkRight(User.java:100)
          at org.h2.command.dml.Update.update(Update.java:87)
  </code></pre>
  
  <p>As you can see it can't run the update statement to get a lock on the DB.</p>
  
  <p><strong>To troubleshoot:</strong> <br>
  1. I opened an h2 shell to run and connect to the h2 db directly:</p>
  
  <pre><code>sudo java -cp h2.jar org.h2.tools.Shell -url "jdbc:h2:file:/usr/share/tomcat/ellucianmobile/banner-mobileserver/banner-mobileserver-prodD" -driver "org.h2.Driver" -user "sa" -password "" 
  </code></pre>
  
  <ol start="2">
  <li><p>I then listed out the tables: </p>
  
  <pre><code>sql&gt; SHOW TABLES; 
  TABLE_NAME | TABLE_SCHEMA  
  BUILDING_DOMAIN | PUBLIC 
  CALENDAR | PUBLIC 
  CAMPUS_DOMAIN | PUBLIC  
  CATEGORY | PUBLIC 
  CONFIGURATION_DOMAIN | PUBLIC 
  DATABASECHANGELOG | PUBLIC 
  DATABASECHANGELOGLOCK | PUBLIC 
  ENTRY_CACHE | PUBLIC 
  ENTRY_CACHE_LINK | PUBLIC  
  ENTRY_DOMAIN | PUBLIC 
  EVENT | PUBLIC 
  EVENT_CATEGORIES | PUBLIC  
  FEED_CACHE | PUBLIC 
  FEED_CACHE_LINK | PUBLIC  
  MS_DEVICE | PUBLIC 
  MS_DEVICEUSER | PUBLIC 
  MS_NMESSAGE | PUBLIC 
  MS_NOTIFICATION | PUBLIC 
  MS_NOT_DEL_REC_DOMAIN | PUBLIC  
  MS_NSTATUS | PUBLIC 
  MS_RECIPIENT | PUBLIC 
  MS_RECIPIENT_STATUSES | PUBLIC  
  NOTIFICATION_DELIVERY_DOMAIN | PUBLIC  
  NUMBERS_DOMAIN | PUBLIC 
  REGISTRATION_CART | PUBLIC 
  SYSTEM_DATA_DOMAIN | PUBLIC 
  (26 rows, 28 ms)
  </code></pre></li>
  <li><p>I can SELECT rows from a given table: <br>
  (As you can see below locked is set to FALSE)<br> </p>
  
  <pre><code>sql&gt; SELECT * FROM DATABASECHANGELOGLOCK;
  ID | LOCKED | LOCKGRANTED | LOCKEDBY 
  1 | FALSE | null | null
  (1 row, 1 ms)
  </code></pre></li>
  <li><p>Since reading worked I tried to write to the DB: <br> </p>
  
  <pre><code>sql&gt; UPDATE DATABASECHANGELOGLOCK SET LOCKED=FALSE, LOCKGRANTED=null, LOCKEDBY=null where ID=1; 
  
  Error: org.h2.jdbc.JdbcSQLException: The database is read only;
  </code></pre></li>
  </ol>
  
  <p>The same error that tomcat is getting when it tries to run an UPDATE to get a lock. </p>
  
  <p><strong>What can I do to make the h2 db available for read AND write by default?</strong></p>