Saturday, November 30, 2013

3 Steps to Run H2 Database in Ubuntu server remote

Step 1: Pre-requisite: make sure you have Java installed from your machine

Step 2: From you console / terminal download H2 Database jar file:
wget http://repo1.maven.org/maven2/com/h2database/h2/1.3.174/h2-1.3.174.jar 
Step 3: Execute the command below from the (one-line)
java -cp ./h2-1.3.174.jar org.h2.tools.Server -web -webPort 8081 -webAllowOthers -tcp -tcpPort 8082 -tcpAllowOthers -baseDir [data_folder_location]
Now let's verify if the server is running.

Open a browser from a different machine and type the IP address of your Ubuntu server and port 8081 (i.e. http://[IP_ADDRESS]:8081). This will display the remote console web UI for your H2.


After connecting to the database, you will see a new file created from [data_folder_location]and an Admin Console will display from your browser (pls refer screenshot below). You can start creating your schema, tables, etc.



Note: If you don't have Java installed from your Ubuntu server, the H2 database will not work. To verify if you have Java version "java -version". For more information regarding Java installation from Ubuntu please visit the link http://interface101.blogspot.com/2013/11/how-to-download-java-7u45-ubuntu.html

Hope this will guide for those who are looking for quick configuration of H2 Database. 

If you have any questions or comments, please don't hesitate to comment below.

5 comments:

Anonymous said...

Informative and simple. Thank you for sharing... If I run the command from a Ubuntu then exit from the console, the process also terminated, how can I make it stay in background even if I exist or logout?

Anonymous said...

I mean "exit" and quit the session but the process will still continue to run...

Unknown said...

Cool! Is there a way to secure the console with a username and a password?

Anonymous said...

How we can uninstall H2 database from ubuntu machine ?

i360 said...

It's simple, just delete the JAR file and if you don't need the data, just delete the data_folder_location using "sudo rm -r data_folder_location" to remove everything.