Akil Vohra
Akil Vohra

Reputation: 43

Issue with Sentry JDBC Integration and P6Spy Connection URL Approach in Spring Boot Project

Problem Description:

I have successfully integrated Sentry JDBC into my Spring Boot project following the documentation here. To implement the integration, I opted for the "Connection URL way" as outlined in the P6Spy documentation here since I am not directly using the Spring Datasource. My project is running on Postgres 15.

However, I encountered an unusual issue where some of my queries are failing with the following error message:

PSQLException: ERROR: improper qualified name (too many dotted names): com.p6spy.engine.wrapper.preparedstatementwrapper
  Position: 23

Upon further investigation, I identified the exact query causing the problem:

SELECT COUNT(*) FROM (com.p6spy.engine.wrapper.PreparedStatementWrapper@7b30fd4a) AS count_query;

Code Snippet:

Here's the relevant code snippet from my project:

private static final String CREATE_PAGINATION = "SELECT COUNT(*) FROM (%s) AS count_query;";
private static final String PATTERN_TO_REMOVE = "LIMIT\\s+\\d+\\s+OFFSET\\s+\\d+";

public Pagination createPagination(Connection conn, String QUERY, int page, int size) throws SQLException {
    final String COUNT_QUERY = String.format(CREATE_PAGINATION, QUERY.replaceAll(PATTERN_TO_REMOVE, ""));
    try (PreparedStatement countPs = conn.prepareStatement(COUNT_QUERY);
         ResultSet rs = countPs.executeQuery()) {
        rs.next();
        long total = rs.getLong(1);
        return createPagination(page, size, total);
    }
}

Request for Assistance:

I need help resolving this issue. It seems that the generated query includes a reference to the com.p6spy.engine.wrapper.PreparedStatementWrapper, and this is causing problems with the PostgreSQL database. How can I address this error and ensure proper query execution?

Any insights or guidance on resolving this issue would be greatly appreciated.

Thank you!

Upvotes: 1

Views: 151

Answers (0)

Related Questions