[KShare] Executing Database Queries in Katalon Studio

Hi Community members, :wave:

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

  1. We will need a free DB host named Free SQL Database
  2. Also, a free Email host called Home

  1. 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 :+1: or a heart :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.

2 Likes

Thank you the Product Support team (@support.squad) and Linh Nguyen @linh.nguyen for another insightful article!

Linh Nguyen
Linh Nguyen (@linh.nguyen) - Product Support Manager at Katalon
Linh is the Product Support team Manager at Katalon. She spent many years working as an Automation Testing QA before joining Katalon Product Support as a technical support expert. Based on her experiences, she usually provides consumers with highly applicable solutions. She now manages her team with a user-centric approach to guarantee customers greater success with Katalon Products.
1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.