So I am attempting to intercept calls designed to a database. At this time I've got a java program which listens for notices (calls produced by various programs). I am attempting to extend this to analyse queries produced by one of these simple programs towards the database, which utilizes the Hibernate ORM.

I am searching in the Hibernate Interceptor which appears very worthwhile. How could I integrate the Interceptor into my program? I am unsure the way i may use it for connecting using the other programs to pay attention for calls. Or would the Listener be a better option?

Thanks, Harry

You're most likely searching for a proxy JDBC driver. These wrap an ordinary JDBC driver and log what's going on.

An example is log4jdbc, I am sure you will find others.

The positive thing about these is the fact that you don't have to improve your program, only the title from the JDBC driver it uses.

To Integrate Hibernate interceptor inside your program, you need to adopt these measures:

  1. Produce a class which stretches hibernate's EmptyInterceptor.

  2. Implement the techniques that are highly relevant to your requirement.

  3. Place it towards the Configuration, as

    Configuration cfg = new Configuration()

    cfg.setInterceptor(new YourInterceptor())