Setup of a new DB connection

Prerequisites:

  • Karaf with GV, along with the OPS4J Pax JDBC database adapter installed

It’s generally a good habit to create a new DB connection (also known as datasource), or at least one DB connection for a group of set service operations, which will share the data and therefore the DB.

In order to store a new connection we will need a new configuration file to be deployed under the path:

apache-karaf-x.x.x/etc

Files with the following naming will be imported by GV ESB 4:

org.ops4j.datasource-[DB name].cfg

While the name prefix and extension needs to be set as above, the “DB name” is up to the dev.
Such file will need to store the following properties, to be configured according to the DB server side informations:

  • osgi.jdbc.driver.name= [name of the JDBC driver]
  • pool= [pool version name provided by the JDBC]
  • url= jdbc:[DB HTTP protocol name]:[sub-protocol]:@[DB server ip number]:[port]:[schema name]
  • user= [login name]
  • password= [login password]
  • dataSourceName= [name of the datasource connection]
  • jdbc.pool.maxIdle= [maximum number of non-active connection present]
  • jdbc.pool.maxTotal= [minimum number of active connection present]
  • jdbc.pool.minIdle= [minimum number of non-active connection present]

Setting up an Oracle DB oriented configuration, would be like:

  • osgi.jdbc.driver.name= oracle
  • pool= dbcp2
  • url= jdbc:oracle:thin:@127.0.0.1:1521:GV_SCHEMA
  • user= user_1
  • password= password_1
  • dataSourceName= simpleReportConnection
  • jdbc.pool.maxIdle= 4
  • jdbc.pool.maxTotal= 16
  • jdbc.pool.minIdle= 2

This example is relative to mysql:

  • osgi.jdbc.driver.name= mysql
  • pool= dbcp2
  • url= jdbc:mysql://localhost:3306/finance
  • user= root
  • password= password
  • dataSourceName= finance-ds
  • jdbc.pool.maxIdle= 4
  • jdbc.pool.maxTotal= 16
  • jdbc.pool.minIdle= 2

Note: is necessary that the selected schema is actually present in you db!

Such configuration will set up a connection towards a locally present Oracle DB server, letting use it to a maximum of 16 users.
The dataSourceName is the one to be used for the simple report example.