Data Base Connection using Groovy Script in SOAP UI
- 5 years ago
The Connection string was good .. My issue was it is not loading the jar from external.. The below code finally helped me directly loading the files.. Now my code is working.. Thanks a lot of all of you guys for helping me here....
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def classpathHacker = new com.eviware.soapui.support.ClasspathHacker ()log.info "utils=" + groovyUtils
path = ".../SoapUI-5.4.0/bin/ext"
myfile = new java.io.File(path + "/ojdbc8.jar")
mystring = "file://" + path + "/ojdbc8.jar"
log.info "myfile=" + myfileclasspathHacker.addFile( myfile )
com.eviware.soapui.support.ClasspathHacker.addFile( myfile )
com.eviware.soapui.support.ClasspathHacker.addURL( new URL(mystring) )import groovy.sql.Sql
import groovy.sql.*
import java.sql.SQLException
import oracle.jdbc.driver.*
//import com.eviware.soapui.support.GroovyUtils.*// Set up database connection properties.
def url = 'jdbc:oracle:thin:'
def user = ''
def password = ''
def driver = "oracle.jdbc.driver.OracleDriver"com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("net.sourceforge.jtds.jdbc.Driver")
sql = Sql.newInstance(url, user, password,driver)
def query = ""
def res = sql.execute(query)