June 18, 2012

How to fetch data from custom external DB in bonita using groovy

How to fetch data from custom external DB in bonita using groovy.
Following is the code snippet to fetch data list from external DB. Let say,we want to fetch data from MYSQL. 1) Make connection with MySQL 2) Make query and specify column 3) Make output string

import groovy.sql.Sql;
import com.mysql.jdbc.Driver;

def result = []
Sql sql = providedscripts.BonitaSql.newInstance("jdbc:mysql://localhost:
3306/custdb","root","root", new com.mysql.jdbc.Driver())

sql.eachRow 'select * from table_name;', { result += it.col_name }
sql.close()

result
Please let me know for any further clarifications.

No comments:

Post a Comment