Tomcat JDBC Interceptors

Some interceptors for the Tomcat JDBC pool.

License

License

Categories

Categories

Tomcat Container Application Servers
GroupId

GroupId

ch.ledcom.tomcat.interceptors
ArtifactId

ArtifactId

tomcat-jdbc-interceptors
Last Version

Last Version

0.4
Release Date

Release Date

Type

Type

jar
Description

Description

Tomcat JDBC Interceptors
Some interceptors for the Tomcat JDBC pool.
Project Organization

Project Organization

LedCom
Source Code Management

Source Code Management

https://github.com/gehel/tomcat-jdbc-interceptors

Download tomcat-jdbc-interceptors

How to add to project

<!-- https://jarcasting.com/artifacts/ch.ledcom.tomcat.interceptors/tomcat-jdbc-interceptors/ -->
<dependency>
    <groupId>ch.ledcom.tomcat.interceptors</groupId>
    <artifactId>tomcat-jdbc-interceptors</artifactId>
    <version>0.4</version>
</dependency>
// https://jarcasting.com/artifacts/ch.ledcom.tomcat.interceptors/tomcat-jdbc-interceptors/
implementation 'ch.ledcom.tomcat.interceptors:tomcat-jdbc-interceptors:0.4'
// https://jarcasting.com/artifacts/ch.ledcom.tomcat.interceptors/tomcat-jdbc-interceptors/
implementation ("ch.ledcom.tomcat.interceptors:tomcat-jdbc-interceptors:0.4")
'ch.ledcom.tomcat.interceptors:tomcat-jdbc-interceptors:jar:0.4'
<dependency org="ch.ledcom.tomcat.interceptors" name="tomcat-jdbc-interceptors" rev="0.4">
  <artifact name="tomcat-jdbc-interceptors" type="jar" />
</dependency>
@Grapes(
@Grab(group='ch.ledcom.tomcat.interceptors', module='tomcat-jdbc-interceptors', version='0.4')
)
libraryDependencies += "ch.ledcom.tomcat.interceptors" % "tomcat-jdbc-interceptors" % "0.4"
[ch.ledcom.tomcat.interceptors/tomcat-jdbc-interceptors "0.4"]

Dependencies

provided (1)

Group / Artifact Type Version
org.apache.tomcat : tomcat-jdbc jar 7.0.37

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.hsqldb : hsqldb jar 2.2.9

Project Modules

There are no modules declared in this project.

Tomcat interceptors

This is my attempt at a Tomcat JDBC interceptor. This interceptor will collect timing and number of calls metrics and publish them to a Statsd server.

The following parameters are required to configure the interceptor:

  • hostname: the hostname of the Statsd server (for example: localhost)
  • port: the port of the Statsd server (for example: 8125)
  • sampleRate: to make sure we don't impact performances too badly, we only get statistics for a fraction of the requests (for example: 0.1)
  • prefix: the prefix used to classify the metrics (for example: myapp.jdbc)

The interceptor can be configured as follow:

<Resource name="jdbc/TestDB"
          type="javax.sql.DataSource"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
          jdbcInterceptors="ch.ledcom.tomcat.interceptors.StatsdInterceptor(hostname=localhost,port=8125,sampleRate=0.1,prefix=myapplication.jdbc)"
          username="myusername"
          password="password"
          [...]
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/mysql"/>

Of course, you will need to add the jar to the Tomcat lib directory. The jar containing this interceptor can be downloaded from Maven Repo1.

Maven generated site available as GitHub pages.

Bitdeli Badge

Versions

Version
0.4
0.3
0.2
0.1