Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8508671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:13:28+00:00 2026-06-11T03:13:28+00:00

I’m facing a problem with log4j and spring JDBC. I may have missed something

  • 0

I’m facing a problem with log4j and spring JDBC. I may have missed something so don’t hesitate to correct me in case of misunderstanding.

I’m currently using a log4j.xml file

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %p %C{1}.%M - %m%n" />
    </layout>
</appender>
<appender name="stationPdf" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="./log/stationPdf.log" />
    <param name="Append" value="true" />
    <param name="MaxFileSize" value="5000KB" />
    <param name="MaxBackupIndex" value="3" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %p %C{1}.%M - %m%n" />
    </layout>
</appender>

<category name="com.mypackage">
    <level value="debug" />
    <appender-ref ref="stationPdf" />
</category>
<category name="org.springframework.jdbc">
    <level value="debug" />
    <appender-ref ref="stationPdf" />
</category>
<root>
    <level value="debug" />
    <appender-ref ref="console" />
    <appender-ref ref="stationPdf" />
</root>

As you could see, it’s mainly redirecting everyhting in a specific file.
The main problem is linked with spring jdbc. I’m using a small database to store properties and I need to connect to this database to extract data.

So, when i make a mistake in the password, i get the following exception, as expected:

    Exception in thread "AWT-EventQueue-0" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:729)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:749)
    at com.mypackage.dao.impl.PropertiesDaoJdbcImpl.selectProperty(PropertiesDaoJdbcImpl.java:37)
    at com.mypackage.data.ExtractedDataClass.loadProperties(ExtractedDataClass.java:42)
    at com.mypackage.accueil.Accueil.<init>(Accueil.java:138)
    at com.mypackage.accueil.Accueil$12.run(Accueil.java:896)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
[...]
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
[...]

Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4098)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4030)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:951)
    [...]

The problem is that I can’t get this exception in my log file. It appears in the console, but never in my file.
What should I use, add or delete to my log4j.xml file to get these exceptions?

Thanks in advance,

Sorry for my approximative English 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:13:29+00:00Added an answer on June 11, 2026 at 3:13 am

    The fact that the error message starts

    Exception in thread "AWT-EventQueue-0"
    

    suggests that it’s not being logged through log4j at all, but simply appearing on the console because of the standard “uncaught exception” logic that every Java thread gets by default, and this would explain why your log4j settings are not having any effect. You’ll need to catch the exception at a suitable point in your own code and log it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.