Friday, October 31, 2014

Execute DB Queries Inside The Mapper

Executing direct SQL queries inside the MEC mapper is not encouraged due to the performance issues, but If you don't have any other solution from APIs from WebServices, you can still use DB queries inside the map.

This is not the "Database" tool available in Mapper toolbar. Inside a Java function, you can use the below to pull some values from the database.

 String sql = "SELECT CFFACI FROM "+schema+".CFACIL WHERE CFCONO="+CONO+" AND CFFANM = "+locationCode;  
 String FACI = "";  
  java.sql.Connection con =      
   com.intentia.ec.db.ConnectionPool.getConnection();  
  java.sql.Statement stmt = con.createStatement();  
  java.sql.ResultSet rs = stmt.executeQuery(sql);  
  if (rs.next())   
  {  
   FACI = rs.getString("FACI").trim();  
  }  
  rs.close();   
  stmt.close();  

No comments:

Post a Comment