Skip to main content
Kinetic Community

Sample Database Count

This is a sample handler that shows you how to count the amount of records are returned in a query to your database using JDBC. The handler will return an xml string containing the amount of records that were counted. For this handler to run properly, a JDBC adapter package must be included in the Kinetic Task web application classpath. The adapter package will take the form of one of more .jar files and will be specific to the database server that it is being connected to.


By downloading this file, you acknowledge that you agree to our Terms of Service

This handler requires that you are running at least Kinetic Task 2.0.

Detailed Description

This handler leverages Java Database Connectivity (JDBC) technology to execute SQL queries against a database server.  JDBC provides an abstract interface for querying against different database systems.  In order to configure a connection, a JDBC Driver must be made available, typically by including a .jar file somewhere on the classpath.  In order to initializing the JDBC connection,
a JDBC driver, or adapter class, associated to the connection must be pre-loaded.  Once the JDBC adapter class is loaded, a simple connection string, which specifies the location of the server, name of the database to connect to and a list of parameters can be used to initialize a connection.

Practically, this means that a JDBC .jar file specific to the target database server will need to be added to the Kinetic Task web application WEB-INF/lib directory.  Additionally, the adapter class and connection string info values will need to be configured specific to the JDBC adapter that is being used to connect.  Below are some example configurations for commonly used JDBC

  Adapter Class:
  Connection String: jdbc:db2://[SERVER][:PORT]/[DATABASE]

Microsoft SQL Server
  Adapter Class:
  Connection String: jdbc:sqlserver://[SERVER][:PORT];databaseName=[DATABASE]

  Adapter Class:     oracle.jdbc.OracleDriver
  Connection String: jdbc:oracle:thin:@//[SERVER][:PORT]/[SERVICENAME]

  Adapter Class:     com.mysql.jdbc.Driver
  Connection String: jdbc:mysql://[SERVER][:PORT]/[DATABASE]

Once you have JDBC configured, you will also need to configure the handler to execute your specific query. In the node.xml file, insert your query in the <config name="query"/> node, using curly braces for the parameters that you wish to be dynamic. Below is an example of a query were the username and name will be dynamic values.

SELECT * FROM Users WHERE name={name} AND username={username}

Any value that you used inside of the curly braces will now need to be added as a parameter. The parameter id must be the same as the value in the curly braces for the query to properly execute. Once all this is configured, the handler will now be able to retrieve a value for you from your desired database!

ParametersEdit section

Name Description
Name Will replace {name} value in query supplied in the config.
Username Will replace {username} value in query supplied in the config.

Sample Configuration

Parameter Example Configuration
Name Test User
Username test.user


Name Description
Count The amount of records that the JDBC query returned.

Change Log

Version Date Description
1 2013-09-25 Initial Version