The bundle persistence enables ConQAT to perform trend analyses for specific metrics.

Basic Concepts

The persistence bundle is based on the following core concepts:

  • Database Connection. The ConQAT database support uses standard JDBC connections to access databases. These are typically instantiated in one processor and then passed to all other processor that access the database.
  • ValueSeries. A value series, defined by DateValueSeries, stores pairs (time x value) and thereby captures the evolution of a value over the time.

HSQLDB

The easiest way to acquaint yourself with the database functionality is to use the HSQLDB database that comes with ConQAT. This small but powerful database engine can work in a standalone mode and store the data to a file. Therefore, it is very convenient to set up.

Configuration

The configuration file example below illustrates the use of the HSQLDatabaseConnector processor to store the evolution of the lines of code (LOC) of a given project.

Configuration

  • The processor db creates a database connection for a simple database based on the file db/example (relative to ConQAT execution directory). If necessary, missing parent directories of the specified file are created automatically.
  • The processor chain src -> loc -> loc-sum collect all Java files, counts lines of code and aggregate by summation. After this operation the total number of lines of code is stored at the root of the tree generated by processor src.
  • This tree is passed to processor loc-series. This processor stores the value found at the root of the tree in the database and creates a value series from all values stored in the database. If the specified database table is not found, the processor automatically creates the missing table.
  • The value series is passed to processor chart that creates a line chart from the series. An important parameter of this processor is the domain resolution that can take any value of enumeration ETimeResolution. The idea hereby is the following: The value series processor always stores its values in the database with a millisecond resolution. However, typically you do not want to compare metric values from one millisecond to the other. Therefore, the resolution of the plot can be set to the desired value, e.g. minute, day, week, etc. If the database stored multiple values for the specified resolution, the last value stored is used.
  • This chart is passed to the output processor output.

Execution

Running the above configuration multiple times generates charts like the ones depicted below. As the lines of code did not change during the first three runs, the chart displays only a line. For demonstration purposes the fourth chart was run on a smaller amount of code.

Database1 Database2 Database3 Database4

Conviently, HSQLDB comes with a nice graphical interface for the database server. This allows you to directly connect to database to ensure it works as intended. To do so, run ant run-hsqldb-interface in the database bundle’s build file (source distribution). This tasks prompts for the name of the database file and starts the HSQLDB GUI. Please note, that in the configuration the database file path was specified relative to the execution directory and not the directory of the database bundle.

Microsoft SQL Server

ConQAT comes with Microsoft’s JDBC implementation. You can conviently connect to a Microsoft SQL Server using the SQLServerConnection block. In the configuration example above you would simply replace the HSQLDB connector with this block and run the same configuration with a Microsoft SQL Server.

You use the properties view to set the properties for the SQL server connection, for example like this:

Sql server props

This block reades the username/password information from a Java properties file whose location is supplied via the ‘file’ attribute of the ‘credentials’ parameter.

Other Databases

As ConQAT’s database support is built on the JDBC standard, every other JDBC-enabled database can be used. However, ConQAT does not come with the required JDBC implementations. To connect to JDBC database, do the following:

  • Copy the database’s JDBC driver to the database bundle’s ‘lib’ directory. This must be a jar-file.
  • Use the JDBCDatabaseConnector to connect to the database. This processor requires the name of the JDBC driver class, authentification information and the standard JDBC connection string. For additional details, please refer to the ConQATDoc.

An example usage of this processor to connect to a MySQL database is:

Mysql props