Groovy script unable to establish Oracle DB Connection

Hi Team,

When tested the Virtual Service in local host with the below Script in the Response tab ---> Input Mode: Scripted---> Language: Groovy getting below error in the when monitored the logs.

Error Message: com.parasoft.api.UserMethodException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Please help me with this issue.

I have added the OJDBC Jar file path in Parasoft --->Preferences ---->JDBC Drivers and restarted the tool.

**Groovy Script:- **

import groovy.sql.*

def ResponseGeneration (context){

sql = Sql.newInstance('jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lok-iuijhb-p1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = qafgkvw) ) )', 'q12ws23', 'testusr', 'oracle.jdbc.driver.OracleDriver')



  • williammccuskerwilliammccusker Posts: 485 ✭✭✭

    Have you tried adding the OJDBC jar file to the system properties instead? Parasoft --> Preferences --> System Properties, I think the jdbc drivers may be a different class loader that is available to SQL related tools but may not be added to the class loader used by scripts.

  • benken_parasoftbenken_parasoft Posts: 973 ✭✭✭
    edited February 2020

    I have added the OJDBC Jar file path in Parasoft --->Preferences ---->JDBC Drivers and restarted the tool.

    I think you likely need to use JDBC API. We have this method which knows how to load classes from the Parasoft JDBC preferences and return a JDBC java.sql.Connection object:

    com.parasoft.api.SQLUtil.getConnection(String driverName, String url, String user, String password) throws SQLException

    Or use this if you want to load the java.sql.Driver object from that other classloader prior to using it for something:

    com.parasoft.api.SQLUtil.getDriver(String driverName) 
Sign In or Register to comment.