Friday, November 8, 2013

WSO2 products & H2 Console

How to query H2 Console while working with WSO2 carbon based product.

There are basically two ways to accomplish above mentioned.

1st method
  • Download H2 database from[1].
  • Extract and cd into the h2/bin directory.
  • Stop your carbon server.
  • Run sh h2.sh.
  • You need to enter correct JDBC URL, User Name and Password and press Connect.
In this approach each time you connect/query H2 Console you have to stop carbon server. (Bit annoying!!!)

2nd method
This is what interests everyone. In this method you don't need to download anything as we are going to use H2 Console embedded in WSO2 Product.
  • Update carbon.xml resides in CARBON_SERVER/repository/conf directory.
  • Search for "H2DatabaseConfiguration" and uncomment configuration parameters as in following screen-shot.
  • Save the configuration file and start carbon server.
  • Browse http://localhost:8082/ in your favorite browser.
  •  Enter correct JDBC URL, User Name and Password and press Connect. In my scenario,
JDBC URL : jdbc:h2:/home/udara/wso2/git/enterprise-store/modules/distribution/target/wso2store-1.0.0/repository/database/WSO2CARBON_DB
User Name : wso2carbon
Password : wso2carbon

You will get the H2 Console now.



[1] http://www.h2database.com/html/download.html

1 comment:

  1. If its a Windows environment we have to use jdbc:h2:file:: as the JDBC URL.

    Eg:- jdbc:h2:file:C:\Users\urathnayake\workspace\WSO2METRICS_DB

    ReplyDelete