Database connection

Hi All,
I currently to connect to SQL server to run a script for my Test case. I have found a video with the solution but when i try it, it fails. It requires a JDBC driver. can anyone advise on where i should install JDBC driver? is it on my local machine or on the SQL server environment?

Below is the error i get :

8-02-2018 02:54:43 PM - [START] - Start Test Case : Test Cases/FicaScript

08-02-2018 02:54:43 PM - [INFO] - Evaluating variables for test case

08-02-2018 02:54:45 PM - [START] - Start action : sqlserverconnection.ExecutingFicaScript.connection

08-02-2018 02:54:45 PM - [ERROR] - java.lang.ClassNotFoundException: com.sqlserver.jdbc.Driver

08-02-2018 02:54:45 PM - [END] - End action : sqlserverconnection.ExecutingFicaScript.connection

08-02-2018 02:54:45 PM - [ERROR] - Test Cases/FicaScript FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.ClassNotFoundException: com.sqlserver.jdbc.Driver

08-02-2018 02:54:45 PM - [END] - End Test Case : Test Cases/FicaScript

Hi,

you can use also Groovy’s Sql library, like this:

import groovy.sql.Sql

public class SQLHandler {	
String dbConnString = "jdbc:sqlserver://server:port"	
String dbUsername = "name"	
String dbPassword = "password"	
String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"	
Sql sql = Sql.newInstance(dbConnString,dbUsername,dbPassword,dbDriver)
}

More info here:
http://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html

3 Likes

hello,
1. find jdbc driver for your DB and download it
2. install it (it will be some .jar file) as external library using project settings
3. from that moment on, you can use it in your scripts (and demo should work too)
this is my oracle jdbc as external lib in katalon

image.png

1 Like