Skip to content

Commit 7c14ed6

Browse files
committed
fix: Do not import SQLException in the SQL handler
The agent was encountering a NoClassDefFoundError for java.sql.SQLException in some environments due to class loading issues. - Removed direct import of java.sql.SQLException. - Changed catch blocks in getDbName methods to catch Throwable instead of SQLException to broaden exception handling and prevent crashes when SQLException is not directly available.
1 parent 8ec4c61 commit 7c14ed6

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • agent/src/main/java/com/appland/appmap/process/hooks

agent/src/main/java/com/appland/appmap/process/hooks/SqlQuery.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.sql.Connection;
44
import java.sql.DatabaseMetaData;
5-
import java.sql.SQLException;
65
import java.sql.Statement;
76

87
import com.appland.appmap.output.v1.Event;
@@ -55,7 +54,7 @@ private static String getDbName(Connection c) {
5554
}
5655

5756
dbname = metadata.getDatabaseProductName();
58-
} catch (SQLException e) {
57+
} catch (Throwable e) {
5958
Logger.println("WARNING, failed to get database name");
6059
e.printStackTrace(System.err);
6160
}
@@ -74,7 +73,7 @@ private static String getDbName(Statement s) {
7473
}
7574

7675
dbname = getDbName(s.getConnection());
77-
} catch (SQLException e) {
76+
} catch (Throwable e) {
7877
Logger.println("WARNING, failed to get statement's connection");
7978
e.printStackTrace(System.err);
8079
}

0 commit comments

Comments
 (0)