Commit 8efee1f
feat: Enhanced JDBC hooks with PreparedStatement and batch support
This commit refactors the SqlQuery hooks to provide comprehensive support
for JDBC operations, particularly PreparedStatements and batch operations.
Key changes:
- Refactored prepareStatement/prepareCall hooks to capture at METHOD_RETURN
and associate SQL strings with the returned statement objects using
WeakHashMaps for proper prepared statement support
- Added comprehensive batch operation tracking (addBatch, clearBatch,
executeBatch, executeLargeBatch)
- Added support for executeLargeUpdate (JDBC 4.2)
- Consolidated overloaded methods using @ArgumentArray to reduce code
duplication and handle all method signatures uniformly
- Added proper exception handling hooks for all execute methods
- Implemented caching of database names using WeakHashMap to avoid
repeated metadata lookups
- Removed nativeSQL hooks (doesn't actually execute SQL, just transforms it)
- Fixed potential NoClassDefFoundError by changing exception handling from
SQLException to Throwable and removing direct class references
The SQLException fix addresses an issue in environments with custom
classloaders (e.g., Oracle UCP) where java.sql.SQLException might not be
visible to the hook class's classloader.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent db1496f commit 8efee1f
File tree
2 files changed
+279
-219
lines changed- agent/src
- main/java/com/appland/appmap/process/hooks
- test/java/com/appland/appmap/process/hooks
2 files changed
+279
-219
lines changed
0 commit comments