Hi Community members,
Are you trying to figure out how to use the Katalon Studio tool’s database queries?
If so, allow us to introduce you to the straightforward scenario that follows to show you how Katalon Studio meets your relevant expectations.
Now, we will show you the database environment used in this demo and the steps we have taken.
1. Prepare the database’s credentials
- We will need a free DB host named Free SQL Database
- Also, a free Email host called Home
- Prepare data by creating tables, columns and rows
Note: We should check the Server information like sql6.freesqldatabase.com before creating a new table.
From the Katalon Studio side, we prepare 3 custom keywords for the purposes below
- Connect to the database (
db_connection
) - Get the expected results from tables (
executeQuery
) - Update the existing data in tables (
executeUpdate
)
@Keyword
def db_connection(String url, String dbname, String port, String username, String pwd) {
String con = "jdbc:mysql://" + url + ":" + port + "/" + dbname
if(connection != null && !connection.isClosed()) {
connection.closed()
}
connection = DriverManager.getConnection(con, username, pwd)
return connection
}
@Keyword
def executeUpdate(String queryString) {
Statement stm = connection.createStatement()
stm.executeUpdate(queryString)
}
@Keyword
def executeQuery(String query) {
Statement stm = connection.createStatement()
ResultSet resultset = stm.executeQuery(query)
return resultset
}
You might be able to better understand the scenario and the steps we wish to provide by watching the videos above.
We would love to share the sample project with you through this link, though, since it would be a better approach for you to save time and learn the concept quickly.
https://dev.azure.com/linhnguyen0979/_git/KShare_DatabaseQueries_KatalonStudio
Additionally, we believe you would need your own database credentials and data to manage this project.
If you find this article helpful, then don’t forget to leave us a like or a heart
and share this article with your colleagues and teammates.
To see more KShare articles, simply navigate to our support tag, or check out our Katalon Community Hub.