Can we execute DB Query in Katalon Studio?

Can we execute SQL in Katalon Studio?

My use case is, I want to fetch some value from Database and match the value which is displayed in UI.

Can I achieve this?

1 Like

yes you can !
what i did was; i created a custom @Keyword to connect to dataBase, and another @Keyword to execute the Query

@Keyword

def connectDB(String url, String dbname, String port, String username, String password){

//Load driver class for your specific database type

String conn = “jdbc:mysql://” + url + “:” + port + “/” + dbname

//Class.forName(“org.sqlite.JDBC”)

//String connectionString = “jdbc:sqlite:” + dataFile

if(connection != null && !connection.isClosed()){

connection.close()

}

@Keyword

def executeQuery(String queryString) {

Statement stm = connection.createStatement()

ResultSet rs = stm.executeQuery(queryString)

return rs

}

//Closing the connection

@Keyword

def closeDatabaseConnection() {

if(connection != null && !connection.isClosed()){

connection.close()

}

connection = null

}

1 Like

How to pass query with join? (Otherwords, i need to pass long query)