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.

How to download Java 7u45 Ubuntu console or terminal using WGET command?

When downloading a Java JDK installer using a simple "WGET" command from Ubuntu terminal or Mac OS terminal, you will end of getting an HTML file because it requires you to click the "Accept agreement..." from the web browser. In my case I need to download it from a console or terminal because my server doesn't have ubuntu-desktop GUI installed.

To make the WGET command work from a terminal or console and download the Java JDK 7, use the command below:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz"
The code snippet above is the command that I used to download the JDK 7u45 into my Ubuntu 12.04 64 bit Server from a terminal perspective. The command is just a one line.

Hope it helps for those who are looking for a quicker way.

That's all.