This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/connect_db_gui_testing.html
This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/connect_db_gui_testing.html
I’m new to Katalon testing and started with DB testing
I created 3 keyword (modified) so as it can connect to my SQL server DB with trusted connection.
- def connectDB - connects as expected
Created the keyword executeQuery
code:
@Keyword
def executeQuery(String queryString) {
try
{
Statement stm = connection.createStatement()
ResultSet rs = stm.executeQuery(queryString)
while (rs.next())
{
System.out.println(rs.getString("ZIP_CD") + " " + rs.getString("COUNTY_NM"));
}
}
// Handle any errors that may have occurred.
catch (SQLException e) {
e.printStackTrace();
}
}
- def executeQuery - it gives me following error:
Cannot invoke method createStatement() on null object
Q: Is it weird that when I execute the a testcase it briefly opens Chrome which is by default ? (Although it’s DB test)
Is the issue related due to browser ?
anyway,
Issue:
Issue I’m getting is at connection.createStatement()
Cannot invoke method createStatement() on null object
Please share your thoughts, views.
where did
com.mysql.jdbc.Connection
move too? It can’t resolve now in latest 7.0.4 version
They seemed to have resolved it to
import java.sql.Connection
So it now joins the other imports such as
import java.sql.DriverManage
import java.sql.ResultSet
import java.sql.Statement
It took me a while to figure this out and get my test running again so hopefully, they can update their Documentation to remove the call for [ import com.mysql.jdbc.Connection ]
yes its resolved to java.sql.Connection
I am getting error while creating db connection object in Katalon Studio 7.3, Earlier the script was working fine in Katalon Studio 6.3.3. Please refer below for the error message:
SQL CMD Exception: Check for Syntax ErrorUnknown system variable ‘performance_schema’/null
private static Connection connection = null;
@Keyword
def connectDB(String server, String port, String dbname, String username, String password){
String url = "jdbc:sqlserver://" + server + ":" + port + ";databaseName=" + dbname + "integratedSecurity=true"
//";user=" + username + ";password=" + password
if(connection != null && !connection.isClosed()){
connection.close()
}
connection = DriverManager.getConnection(url)
return connection
}
getting this esxeption:
java.sql.SQLException: No suitable driver found for jdbc:ABC-EFG-D01\CSTSFC11T:1433;databaseName=XYZ;user=AC;password=1234@Pass;
at java_sql_DriverManager$getConnection.call(Unknown Source)
at New Test Case (1).run(New Test Case (1):39)
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:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1588116266253.run(TempTestCase1588116266253.groovy:23)
i am getting the following error Groovy:unable to resolve class com.mysql.jdbc.Connection. can anyone help
Hi, All
Can we please get an updated example of how to do this? Coping and pasting the old example code is no good as it has errors in the current version.
Thanks
how do we establish a connection to ClickHouse database server