AnsweredAssumed Answered

DB timeout configuration using groovy script

Question asked by hemalatha.ediga793658 on Feb 17, 2017
Latest reply on Feb 21, 2017 by Srinivas Chandrakanth Vangari

import java.sql.*;
import groovy.sql.Sql;

class Example {
static void main(String[] args) {
def sql = Sql.newInstance('jdbc:oracle:thin:@//Localhost:1521/DBNAME', 'User', 'PWD','oracle.jdbc.driver.OracleDriver')
sql.withStatement { stmt -> stmt.queryTimeout = 10 }
sql.eachRow(" SELECT DISTINCT UNIT_COST, TART_DT,ITEM_NUM FROM EXT.TABLE WHERE TRUNC(START_DT) = '01-JAN-2017' and trunc(last_updt_dt)>= '01-JAN-2017'and rownum < 3 "){ row ->
println ([row.UNIT_COST,row.TART_DT,row.ITEM_NUM])
}
}}

 

I am using above script to configure timeout on DB query and retrieve the details from DB.

I am not receiving any error or any response from the query, transaction is hanging at data process step

 

Help me in correcting the query 

 

Outcomes