web stats
Mirth Community - View Single Post - Using JavaScript Objects for Transformations
View Single Post
  #7  
Old 06-28-2019, 06:03 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,238
cory_cole is on a distinguished road
Default

I assume that when you say a SQL DB, you mean SQL Server?

You will need to fill in the specific information for your DB.
var dbConn;
var query = 'SELECT FIELD1 FROM TABLE WHERE FIELD2 = VALUE;
var resultValue = '';
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','dblocation',' username','pwd');
result = dbConn.executeCachedQuery(query);
while(result.next())
{
resultValue = result.getString(1);//assuming it is a string.
}
// You may access this result below with $('column_name')
return result;
} finally {
if (dbConn) {
dbConn.close();
}
}
Reply With Quote