Postgres driver...how does Katalon find the suitable one?

Hello, can someone please illuminate a key issue which we haven’t seen covered in the standard documentation or the other posts related to Katalon/postgres database testing:

We keep getting an error of No suitable driver found for jdbc postgres…

Route 1
Using the Katalon menu wizard, Project → Settings → Database, and following the format jdbc:postgresql://localhost:5432/DB_NAME?currentSchema=SCHEMA with our own variables, when we click Test Connection we see – Connection failed! No suitable driver found for jdbc:postgres://ourdburl:5432/ourtable?currentSchema=public

We’ve downloaded the postgresql-42.2.5.jar file and added it to the Settings → External Libraries input. It seems that we are using Java 8, but I think Katalon might be compiling with a jre7 postgres file by default.

Route 2
We created a custom keyword based on a youtube video for mysql (Database testing using custom keyword in Katalon Studio - YouTube). Error message follows our script below.

****Basically, when we “import” something (how do we know what to import also), do we need that library in a directory folder or how is that import facilitated? and how do we set this up for postgres if the Settings wizard isn’t working? We also put the postgresql-42.2.5.jar file in the Katalon → configuration → resources → lib folder.

package pgConnection

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable
import groovy.sql.Sql
import java.sql.*
import org.postgresql.Driver

public class ExecutingFirstQueryInSql {
	@Keyword
	public connection(String url, String user, String password, String driverClassName){
		
		def sqlConnection = Sql.newInstance(url,user,password,driverClassName)
		
		sqlConnection.eachRow("Show tables") { row ->
				println row[0]
		}
	}
}

We created a test, called pgConnection.ExecutingFirstQueryInSql.connection, and added our variables to the Input dialog (jdbc:postgres://ourdatabaseurl.com:5432/ourtableasdf for url) and then for driverClassName we temporarily inserted com.mysql.jdbc.Driver and also tried org.postgresql.jdbc.* and org.postgresql.Driver
ERROR:

mysqlConnection.ExecutingFirstQueryInMySql.invokeMethod:0

Test Cases/QApg FAILED.
Reason:
org.codehaus.groovy.runtime.InvokerInvocationException: java.sql.SQLException: No suitable driver found for jdbc:postgres://ourdatabaseurl.com:5432/ourtable
at pgConnection.ExecutingFirstQueryInSql.invokeMethod(ExecutingFirstQueryInMySql.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)
at QApg.run(QApg:16)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1545929124450.run(TempTestCase1545929124450.groovy:22)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgres://ourdatabaseurl.com:5432/ourtable
at pgConnection.ExecutingFirstQueryInSql.connection(ExecutingFirstQueryInSql.groovy:27)
at pgConnection.ExecutingFirstQueryInSql.invokeMethod(ExecutingFirstQueryInSql.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)
at Script1545928606760.run(Script1545928606760.groovy:16)
… 11 more

The ql part was missing in the error message. Could you please try adding it and connect again?

Thank your good eyes! That did it.

1 Like