How to import a .db file into h2 database?

3,105 views
Skip to first unread message

Jian Zhang

unread,
Mar 16, 2018, 3:55:03 AM3/16/18
to H2 Database
Hi,

I have a .db file and I don't know how to import into the h2 database since I'm new to this database engine. I have not found any useful instructions yet.  Does someone know how to do with it?

Thanks,
Jian

Adam McMahon

unread,
Mar 16, 2018, 4:10:40 PM3/16/18
to H2 Database
Hi,

I .db file is a native h2 database file.  It does not need to be imported, as it is simply the database itself, it simply needs to be opened.  The are several ways to open and read an h2 .db file, but the easiest way is to use the web interface console.  The quick start guide will be your friend here:  http://www.h2database.com/html/quickstart.html

What is your goal with the H2 file, do you just want to read the contents? Read it from a Java app?  Something else?

Also, note that other databases also use the .db file extension, so if you do not in fact have a native h2 database file, then the process of loading it into h2 is much more complicated.  Let us know where you are getting stuck in the quickstart guide and we will help you out.

-Adam

Jian Zhang

unread,
Mar 17, 2018, 1:26:09 AM3/17/18
to H2 Database
I want to read the contents in the web interface console. I used h2 in server mode and successfully launched it. The problem is that I don't know where should I put the database files(bcb.h2.db and bcb.trace.db).  So, how can I read the contents of the existing database in the web console?

在 2018年3月17日星期六 UTC+8上午4:10:40,Adam McMahon写道:

Adam McMahon

unread,
Mar 18, 2018, 9:24:23 PM3/18/18
to H2 Database
Hi,

You can put the h2 db files wherever you want.  in the h2 web console, point to the h2 db files in the JDBC Url.  Look at this link on how to format the url to reference your file:

http://www.h2database.com/html/features.html#database_url

You will likely want a url for an embedded connection from the h2 consle, that follows the pattern for a file based embedded connection:  http://www.h2database.com/html/features.html#embedded_databases

You may also need to put the user name and password into the web console, if you have it.


-Adam

On Friday, March 16, 2018 at 3:55:03 AM UTC-4, Jian Zhang wrote:
Reply all
Reply to author
Forward
0 new messages