Database access from MarathonITE for test automation through scripts

ManrathonITE test automation tool support test automation through scripts. Since MarathonITE scripts are pure JRuby scripts, you can use any data access gems available to access databases. An alternative is to use JDBC to access the database that we explore in this article.

Step 1: Download JDBC driver

If you haven’t done already, download the JDBC driver for your database. It is a JAR file and might have been provided in your database installation. You require an available JDBC driver before you can perform other steps. For this example, I am using mysql JDBC driver available at


Next, you need make this driver available to MarathonITE runtime. There are two options for doing this.
Set an environment variable
You can set the environment variable from the windows control center (or in your .profile for *nix systems). Set the variable to the following value:
Modify marathonite batch file
Use a text editor and open marathonite.bat file and add the following line just before executing java. Of course, you need to change the path and name for the JDBC jar. test automation through scripts Save your changes and quit the editor. From now, you can access the JDBC driver from your script.

Step 3: Create connection

Use DriverManager#getConnection call as follows to create a connection object. The connection_string format varies by the JDBC driver. Look at your JDBC driver documentation for the correct format and parameters to the get_connection call.

Step 4: Create your query

A query is a regular string. Construct the string using regular ruby statements. You can use the values you get using get_p from the screen if required.

Step 5: Execute SQL

Use the connection to create a statement object and execute query. If the query is successful, you will receive a result set.

Step 6: Iterate the result set

Use do..while to iterate the result.

Step 7: Close connections

Finally, you should close the release the JDBC objects.