File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes jdbcappender log4j:ERROR Failed to excute sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "jdbcappender log4j:ERROR Failed to excute sql" Watch "jdbcappender log4j:ERROR Failed to excute sql" New topic

jdbcappender log4j:ERROR Failed to excute sql

Rolley Jain

Joined: Apr 10, 2012
Posts: 2
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?
I agree. Here's the link:
subject: jdbcappender log4j:ERROR Failed to excute sql
It's not a secret anymore!