Announcement Announcement Module
No announcement yet.
JdbcTemplate: logging sql statement just like hibernate? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JdbcTemplate: logging sql statement just like hibernate?

    I'm developing an application where I have both Hibernate and direct jdbc access (to two different databases, one new, one legacy).

    I like the way Hibernate logs the sql statements, and I'm wondering, is there any flag I can raise to make Spring log the sql statements provided to the hibernate template just like hibernate does? I mean only the sql statements, not a debug level logging with all inside...

  • #2
    You can check the sources but AFAIK there is no such flag. You could raise an enhancement on the JIRA for that (and provide a nice example as guide ).


    • #3
      I guess we could add a flag for this. With Hibernate it is a needed feature since you don't write the sql statements yourself, but with the JdbcTemplate you are in control of the SQL and I don't see this as that important. I often use p6spy to log all the statements during developmnet and this works well. If you really need this feature add it as a feature request to our JIRA issue tracker.


      • #4
        you could always add this to your log4j.xml file...

            <category name="org.springframework.jdbc.core.JdbcTemplate" additivity="false">
                <priority value="debug" />
                <appender-ref ref="stdout" />
        If you are using Thomas's JdbcTemplate anyway.