How to enable logging for SQL statements when using JDBC
Problem:
You're struggling to enable logging with a JDBC program while connecting to an Oracle database in Eclipse. You've followed the steps mentioned in a SO post but haven't observed any logs generated by the JDBC driver classes.
Solution:
While log4jdbc provides an alternative solution for logging JDBC statements, the original issue can be resolved by addressing the following aspects:
-
Classpath: Ensure that the correct JDBC driver (e.g., ojdbc6dms.jar) is included in the classpath and not replaced by an incompatible version like ojdbc6_g.jar.
-
Logging Configuration: Double-check the content of the OracleLog.properties file. Make sure it matches the expected format and there are no issues with the logging level or handler settings.
-
MBean Availability: The error "InstanceNotFoundException" indicates that the MBean for enabling logging is not available. Try updating the JDK version or adjusting the Java Virtual Machine (JVM) startup arguments to include the required MBean class.
Once these issues have been addressed, the logging should work as intended. You can now expect to see logs generated by the JDBC driver classes during the execution of your JDBC program.
The above is the detailed content of Why Aren't My JDBC SQL Statements Logging in Eclipse?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn