Hmmm, sorry if its a dumb question but isn't that what i'm doing?
String fileContents = new File('C:/tmp/DBChosen.txt').text
if (fileContents.matches("SQL14")){
String connectionUrl = "jdbc:sqlserver://" + db_server + ":" + db_port +
";database=" + db_database +
";user=" + db_user +
";password=" + db_password;
sql = Sql.newInstance( connectionUrl, "com.microsoft.sqlserver.jdbc.SQLServerDriver")
}
else if (fileContents.matches("ORA12")){
String connectionUrl = "jdbc:oracle:thin:/@mred_oradb/mred_oradb@//strad:1521:ora123"
sql = Sql.newInstance( connectionUrl, "oracle.jdbc.driver.OracleDriver")
}
//Select data and return values
sql.eachRow("select VALUE from SP083_SYSTEM_PARAMETERS Where NAME = 'sp100_audit'") { p ->
log.info "VALUE = ${p.VALUE}"
}
sql.close()
The line it doesn't like and is throwing the "No such property: sql for class" error is the below which is because i thought it was a local scope within the if statement
sql.eachRow("select VALUE from SP083_SYSTEM_PARAMETERS Where NAME = 'sp100_audit'") { p ->
log.info "VALUE = ${p.VALUE}"