I created a H2 database with my code with this URL:
jdbc:h2:C:/data/fixed.db
My code can create tables, perform queries. If I open the file manually, I can successfully see its content and view the create queries etc
However, when I try to use H2 console with the web interface, I can't see the database. Instead, the web console create another empty database located here C:/data/fixed.db.mv.db
. I just can't load my database.
What am I missing ?
EDIT
My code uses H2 1.3.175
The web console H2 1.4.178
Accessing the H2 Console H2 database has an embedded GUI console for browsing the contents of a database and running SQL queries. By default, the H2 console is not enabled in Spring. Then, after starting the application, we can navigate to http://localhost:8080/h2-console, which will present us with a login page.
Finally I solved my problem...
Since 1.4.x, H2 uses MV_STORE (see SO answer here and Thomas Mueller comment).
Apparently, the web console tries to append automatically a .mv.db
extension. Even if there is already a file with the h2.db
extension.
So , I upgrade the H2 version of my code from 1.3.175 to 1.4.178 and finally, I can see my data...
EDIT
Here is an alternative solution proposed by @devdanke:
You must manually tell your H2 1.4.x not to use MV_Store: ";mv_store=false". What a hassle.
For example, you would end with a code similar to:
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection( //
"jdbc:h2:file:C:\\my\\java\\projects\\test;mv_store=false" //
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With