This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbcappender log4j:ERROR Failed to excute sql

Rolley Jain
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

My log4j.xml file has the following code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >

<appender name="JDBC" class="org.apache.log4j.jdbc.JDBCAppender">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="URL" value="jdbc:mysql://localhost:3306/LOGSDB"/>
<param name="user" value="root"/>
<param name="password" value="root"/>
<param name="sql" value="INSERT INTO LOGS(USER_ID,DATED,LOGGER,LEVEL,MESSAGE) VALUES('%x' , '%d{yyyy-MM-dd}' , '%C', '%p' , '%m')"/>
<layout class="org.apache.log4j.PatternLayout"/>

<logger name="log4j.rootLogger" additivity="false">
<level value="debug,info"/>
<appender-ref ref="JDBC"/>

<priority value="debug"></priority>
<appender-ref ref="JDBC" />


And when i run it it gives me following error:

log4j:ERROR Failed to excute sql
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Debug' at line 1
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.Statement.executeUpdate(
at com.mysql.jdbc.Statement.executeUpdate(
at org.apache.log4j.jdbc.JDBCAppender.execute(
at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(
at org.apache.log4j.jdbc.JDBCAppender.append(
at org.apache.log4j.AppenderSkeleton.doAppend(
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(
at org.apache.log4j.Category.callAppenders(
at org.apache.log4j.Category.forcedLog(
at org.apache.log4j.Category.debug(
at obe.coherence.SimpleCacheTest1.doGet(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at weblogic.servlet.internal.StubSecurityHelper$
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(
at weblogic.servlet.internal.ServletStubImpl.execute(
at weblogic.servlet.internal.ServletStubImpl.execute(
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(
at weblogic.servlet.internal.WebAppServletContext$
at weblogic.servlet.internal.WebAppServletContext.securedExecute(
at weblogic.servlet.internal.WebAppServletContext.execute(

Can some one please point out the issue my code must be having?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic