Home >Java >javaTutorial >Why does my H2 in-memory database show a \'Table not found\' error after creating a table?
When connecting to an H2 database in memory using the "jdbc:h2:mem:test" URL, users may encounter a "Table not found" error despite creating the table previously. This anomaly arises due to H2's default behavior of closing the connection after DDL operations, leading to the table becoming inaccessible.
To remedy this issue, modify the connection URL by appending ";DB_CLOSE_DELAY=-1" to keep the database open persistently, preventing the table from being discarded. The modified URL should look similar to this:
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
By incorporating this change, H2 will retain the database content until the virtual machine is terminated, ensuring that any created tables remain intact.
The above is the detailed content of Why does my H2 in-memory database show a \'Table not found\' error after creating a table?. For more information, please follow other related articles on the PHP Chinese website!