Logging SQL Statements from HSQLDB

I am using HSQLDB in my application. Now I need to register every executed sql statement. I do not want to handle SQL logging myself. Is there a standard way to do this from within HSQLDB?

+4
source share
2 answers

HSQLDB 2.2.x supports SQL logging. Suppose your database is called test , and you connect using the JDBC url jdbc:hsqldb:file:test

  • test.log is the data change log used inside HSQLDB. It does not contain SELECT statements. It is created and deleted by HSQLDB. This is not what you are looking for.

  • test.sql.log is a log containing all SQL statements with time and session information, as well as any arguments for prepared statements. This log is created if you use:

    SET DATABASE EVENT LOG SQL LEVEL 3

It contains entries such as:

 2012-02-08 22:19:36.484 DETAIL 4 CALL USER() 2012-02-08 22:19:36.484 DETAIL 4 call database_version() 2012-02-08 22:19:36.484 DETAIL 4 COMMIT 2012-02-08 22:19:36.500 DETAIL 4 INSERT INTO Customer VALUES(0,'Laura','Steel','429 Seventh Av.','Dallas') 

You can use hsqldb.sqllog = 3 in the URL

  1. test.sql.app.log is a log containing entries for internal save operations. This is not related to executable SQL operations.

See the manual here and check the command syntax and properties at the end of the chapter:

http://hsqldb.org/doc/2.0/guide/management-chapt.html#mtc_monitoring_operation

+8
source

It is not dependent on HSQLDB, but if your client uses JDBC, perhaps the easiest way to register SQL statements is to use the JDBC driver shell. There are many options.

+1
source

Source: https://habr.com/ru/post/1395401/


All Articles