Skip to content

Add an ability to log SQL queries executing in JdbcTemplate class provided by JdbcPollingChannelAdapter class when debug is enabled. #2727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
morozovivan95 opened this issue Feb 1, 2019 · 1 comment · Fixed by #2730

Comments

@morozovivan95
Copy link

Affects Version(s): 5.1.2.RELEASE

There is a log message written in JdbcTemplate starting with "Executing prepared SQL statement", but it remains not continued with actual SQL query being executed due to the fact that JdbcPollingChannelAdapter does not implement SqlProvider interface.

Are there any significant reasons not to provide this functionality which leads to absence of such an important debug information?


@morozovivan95 morozovivan95 changed the title Add an ability to log SQL queries executing in JdbcTemplate class provided by JdbcPollingChannelAdapter class when debug is enabled. Add an ability to log SQL queries executing in JdbcTemplate class provided by JdbcPollingChannelAdapter class when debug is enabled. Feb 1, 2019
@artembilan artembilan added this to the 5.1.3 milestone Feb 1, 2019
@artembilan artembilan self-assigned this Feb 1, 2019
artembilan added a commit to artembilan/spring-integration that referenced this issue Feb 1, 2019
Fixes: spring-projects#2727

The `JdbcTemplate` logs a message for the sql to execute when it is
supplied by the `QueryProvider`.

* Refactor `JdbcPollingChannelAdapter` to use new introduced internal
`PreparedStatementCreatorWithMaxRows` with the `QueryProvider`
* Refactor `JdbcMessageHandler` to instantiate a `generatedKeysStatementCreator`
based on the `PreparedStatementCreatorFactory`
* Verify in the `JdbcOutboundGatewayParserTests` that both fixes logs
sql queries properly
@artembilan
Copy link
Member

Thank you for the report, @morozovivan95 !

I found similar problem in the JdbcMessageHandler.
Wasted time to figure out how to simplify our code over there, but looks like there is just on way with the current JdbcTemplate API...

artembilan added a commit to artembilan/spring-integration that referenced this issue Feb 1, 2019
Fixes: spring-projects#2727

The `JdbcTemplate` logs a message for the sql to execute when it is
supplied by the `QueryProvider`.

* Refactor `JdbcPollingChannelAdapter` to use new introduced internal
`PreparedStatementCreatorWithMaxRows` with the `QueryProvider`
* Refactor `JdbcMessageHandler` to instantiate a `generatedKeysStatementCreator`
based on the `PreparedStatementCreatorFactory`
* Verify in the `JdbcOutboundGatewayParserTests` that both fixes logs
sql queries properly
garyrussell pushed a commit that referenced this issue Feb 8, 2019
* GH-2727: Ensure JDBC queries are logged

Fixes: #2727

The `JdbcTemplate` logs a message for the sql to execute when it is
supplied by the `QueryProvider`.

* Refactor `JdbcPollingChannelAdapter` to use new introduced internal
`PreparedStatementCreatorWithMaxRows` with the `QueryProvider`
* Refactor `JdbcMessageHandler` to instantiate a `generatedKeysStatementCreator`
based on the `PreparedStatementCreatorFactory`
* Verify in the `JdbcOutboundGatewayParserTests` that both fixes logs
sql queries properly

* * Implement all the delegate interfaces for the `PreparedStatementCreatorWithMaxRows`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants