I tried using the Groovy script below to connect to an Oracle SQL :
def connectDB(String dataFile){ //Load driver class for your specific database type Class.forName("oracle.jdbc.driver.OracleDriver") String connectionString = "jdbc:sqlite:" + dataFile if(connection != null && !connection.isClosed()){ connection.close() } connection = DriverManager.getConnection(connectionString) return connection }
There is sqlite in the connection string, but not sure what value I should use there. (I also tried jdbc:oracle .)
I use the following class to connect to the database.
public class sqlconnect { private static Connection connection = null; @Keyword def connectDB(String dataFile){
I already installed the database information under Project > Settings > Database in Katalon Studio. I call from testcase using the CustomKeyword connectDB() and executeQuery() methods.
UPDATE:
I updated the connectDB() method of the Groovy script:
def connectDB(){ Class.forName("oracle.jdbc.driver.OracleDriver") //String connectionString = "jdbc:oracle:thin:username/ password@ipaddress :port/servicename" if(connection != null && !connection.isClosed()){ connection.close() } connection = DriverManager.getConnection("jdbc:oracle:thin:username/ password@ipaddress :port/servicename", "username", "password") return connection }
I tried to use the connectionString variable as a parameter to the DriverManager.getConnection() method, but in both cases I got the same error message.
Unable to pass object 'oracle.jdbc.driver.T4CConnection @' with class 'oracle.jdbc.driver.T4CConnection' to class 'Com.mysql.jdbc.Connection'
source share