Forum Discussion

Mr_Bro's avatar
Mr_Bro
Frequent Contributor
2 years ago

how to load driver jar file to connect to database

Hello All,

 

request you to please suggest how to load an external driver .jar to connectc to database, as i have have required access to add any files or modify any existing files from the c:\ drive (were the SoapUI is installed)

 

thanks in advance 

  • try this

     

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def classpathHacker = new com.eviware.soapui.support.ClasspathHacker ()
    
    log.info "utils=" + groovyUtils
    path = groovyUtils.getProjectPath()
    myfile = new java.io.File(path + "/ojdbc14.jar")
    mystring = "file://" + path + "/ojdbc14.jar"
    log.info "myfile=" + myfile
    
    classpathHacker.addFile( myfile )
    com.eviware.soapui.support.ClasspathHacker.addFile( myfile )
    com.eviware.soapui.support.ClasspathHacker.addURL( new URL(mystring) )
    
    import groovy.sql.*
    def sql = groovy.sql.Sql.newInstance( db, userid, password, 'oracle.jdbc.driver.OracleDriver' )

     

    https://community.smartbear.com/t5/SoapUI-Open-Source-Questions/Soapui-is-not-loading-external-jar-file-location-added-to/td-p/7619 

  • Mr_Bro's avatar
    Mr_Bro
    Frequent Contributor

    Shashavali ,

     

    the administrator has restricted access to any sub folder under C: drive.

     

    is it possible to load the driver from any given file location?.

     

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    Mr_Bro 

    If the above file is required, then I believe your system admin can fulfill your request, just please check.

     

    Any user libraries placed under SOAPUI_HOME/bin/ext directory are loaded by the tool automatically.

  • nmrao's avatar
    nmrao
    Champion Level 3
    If you still have issues loading the database driver library, you may placing the under SOAPUI_HOME/lib directory and restart the tool