Database Connections

Access 3rd party databases

  • Boodskap offers a very convenient and simple API to access 3rd party databases that are ODBC / JDBC complaint
  • You can configure multiple database connections and access data from various sources
  • A simple Context API to query the tables

Connection Samples

{
    "jdbcUrl": "jdbc:postgresql://localhost:5432/sensordb",
    "username": "postgres",
    "password": "********",
    "driverClassName": "org.postgresql.Driver",
}

🚧

JDBC Driver

You have to drop in all the JDBC driver library files under the libs directory of the platform installation root.

Query Samples

CREATE TABLE WATERPARAMS(
   ID TEXT PRIMARY KEY     NOT NULL,
   DEVICE          TEXT    NOT NULL,
   NH3             INT     NOT NULL,
   NH4             INT     NOT NULL,
   O2              INT     NOT NULL
);
INSERT INTO WATERPARAMS(
        ID, 
        DEVICE, 
        NH3, 
        NH4, 
        O2
    )  
    VALUES (
        'UniqueId', 
        'MySensor', 
        233, 
        675, 
        7
    )
select * from WATERPARAMS;
{
    "records": [{
        "id": "UniqueId",
        "device": "MySensor",
        "nh3": 233,
        "nh4": 675,
        "o2": 7
    }]
}

Example Rules Integration

try{
    def targs = [:];
    
    targs['id'] = msg.id;
    targs['device'] = msg.deviceid;
    targs['nh3'] = msg.nh3;
    targs['nh4'] = msg.nh4;
    targs['o2'] = msg.o2;
    
    db.execute('DEV_DB', 'insert_wp', targs);

}catch(Exception ex){
    log.error(ex);
}
INSERT INTO WATERPARAMS( ID,  DEVICE,  NH3,  NH4, O2 )  
VALUES (
        '{{id}}', 
        '{{device}}', 
        {{nh3}}, 
        {{nh4}}, 
        {{o2}}
);