How to start a server and create memory database with H2
236 views
Skip to first unread message
Tommi Korhonen
unread,
Nov 15, 2016, 9:23:09 AM11/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hello H2 users!
I'm a newbie with H2. I've been browsing the documentation, but haven't been able to found a good example for what I need. Hopefully someone could help me with this. I'm looking for a script that
starts an H2 as a server
creates a memory database
loads 'create table' -statements from a file and executes them
loads data from csv-files and inputs data into tables (or links tables from a Postgres database)
Tommi Korhonen
unread,
Nov 16, 2016, 7:51:06 AM11/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
I'm answering to myself. This is what I have so far.
# stop the server if already running java -cp /path_to/h2/bin/h2-1.4.193.jar org.h2.tools.Server -tcpShutdown tcp://localhost # start the server, allow access outside localhost java -cp /path_to/h2/bin/h2-1.4.193.jar org.h2.tools.Server -webAllowOthers -tcpAllowOthers -pgAllowOthers & # start command-line client. first connection creates database java -cp /path_to/h2/bin/h2-1.4.193.jar org.h2.tools.Shell -url "jdbc:h2:tcp://localhost/mem:mydb;DB_CLOSE_DELAY=-1;INIT=runscript from 'init_database.sql' -sql ""
This seems to work.
Petr Holík
unread,
Nov 16, 2016, 1:56:37 PM11/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hello,
all that you ask /as you proved/ can be found on H2 site. Sometimes its little bit hidden ;-)
Just reminder that for importing csv is function CSVREAD.