Thanks .. I followed that link and I could able to do it..
I'm storing values of DB connection in a file and reading that file to create my DB connection string.
please tell me if any more efficient step to do this.
import groovy.sql.Sql;
def DB_prp= new Object[4]; //array to store the db properties
def results;
def DB_connection;
//Groovy open file for reading DB related properties
def target ="D:\\soapui-release-B\\properties\\DB_connection.csv"
def i=0;
def FILE_NOT_EXISTS="$target file NOT present";
File wf= new File(target);
assert wf.exists():FILE_NOT_EXISTS;
wf.eachLine{line->
results = line.tokenize("\t");
//log.info results[1];
DB_prp[i++]=results[1].trim();
}
//for (item in DB_prp) {
//log.info item;
//}
try {
DB_connection = Sql.newInstance(DB_prp[0], DB_prp[1],DB_prp[2],DB_prp[3]);
context.setProperty("dbConn", DB_connection);
} catch (Exception e) {
log.error "Could not establish connection to the database."
}
in the teardown script I'm closing the connection
//Close db connection
if (context.dbConn)
{
context.dbConn.close();
log.info "Closed Database Connection."
}