Hi,
that is really not quite easy to solve. The JDBC driver does not pass any class information or stack info as far as I know.
There could be object relational mappers involved, like hibernate , which do create the SQL internally and you would not
find the SQL even in the source code directly, because it is constructed internally.
If you assume that plain JDBC is being used, you might be able to identify the classes or at least the candidates
by searching the .class files for string fragments.
Since the jar is only a zip, you can unpack everything in the filesystem and either search the files for constants which contain parts of your sql
| A standalone Java Decompiler GUI. Contribute to java-decompiler/jd-gui development by creating an account on GitHub. github.com |
jd-gui is able to decompile java11 code at least, for higher versions, there are other tools available.
If you are getting really unreadable code, the code is probably obfuscated. Then it is really complex to find the source class,
because all classes would have very cryptic names.
The Informix server side will not know which class is issuing the query, it only knows the class which started the connection,
which would usually be some kind of datasource pooling software, the version of your driver,
the user which was used for authentication and maybe the tty it is running in (for a Linux/Unix application server).
I am not aware of any property you might pass to the driver in order to get this information to the server side.
A java deleoper would maybe create some code with aspectj and intercept the method calls of IfmxStatement and IfmxPreparedStatement
and print out the sql and stack trace dynamically to a file so you would get the exact call stack for each statement.
(if the code is compiled with debug info also the line of code).
This would require an experienced java developer and aspectj needs to be added as a startup javaagent to your tomcat container.
Easiest solution is of course to have access to the source code which seems not to be the case for you.
Good luck,
Original Message:
Sent: 3/28/2024 8:49:00 AM
From: Antonin Rozehnal
Subject: SQL command identification/source
I am involved in the operation of a large multi-user system with hundreds of users.
The application code is written in Java and Infomix 4gl. I am able to monitor the current traffic and identify possibly suboptimal SQL statements (e.g. using onstat -g ...).
However, I often have trouble tracking down the appropriate source file for a particular SQL statement. Respectively, I don't have this problem with 4GL, because "onstat -g ses XZX" prints the name of the 4ge binary. But all Java code is executed on the server under one virtual user. The Java code includes about several thousands Java files. How to identify the appropriate file for a particular SQL,or user session in such a large number?
------------------------------
Antonin Rozehnal
------------------------------