Sounds like we need a JIRA to track and fix this...

Gary

On Wed, Jul 22, 2015 at 12:09 PM, Benjamin Jaton <[email protected]>
wrote:

> I just tried it and it produces the same error.
>
> column.layout.toSerializable(event) always produces a non-null String
> because it is based on a StringBuilder.
>
> So I don't think there is even a way for the code to set a column to NULL,
> it will always be set to the Strings "" or "NULL", even if I write a custom
> PatternConverter.
>
>
> On Tue, Jul 21, 2015 at 5:21 PM, Remko Popma <[email protected]>
> wrote:
>
> > Have you tried ThreadContext.remove("NUM")?
> >
> > Remko
> >
> > Sent from my iPhone
> >
> > > On 2015/07/22, at 7:45, Benjamin Jaton <[email protected]>
> wrote:
> > >
> > > Hello,
> > >
> > > I am using the JDBCAppender:
> > >
> > > {
> > >  "type" : "Jdbc",
> > >  "name" : "MyDatabaseAppender",
> > >  "tableName" : "LOGS",
> > >  "ignoreExceptions" : "false",
> > >  "ConnectionFactory" : {
> > >    "class" : "test.ConnectionFactory",
> > >    "method" : "getDatabaseAppenderDataSource"
> > >  },
> > >  "Column" : [
> > >     { "name" : "ID", "pattern" : "%X{ID}", "isUnicode" : "false" },
> > >     { "name" : "NUM", "pattern" : "%X{NUM}", "isUnicode" : "false" }
> > > ]
> > > }
> > >
> > > As you can see, I am using the ThreadContext to pass the variables.
> > >
> > > ThreadContext.put("ID", id++);
> > > ThreadContext.put("NUM", "41");
> > >
> > > The NUM column is of type BIGINT, and is nullable.
> > >
> > > I am trying to set it to NULL with:
> > >  ThreadContext.put("NUM", "NULL");
> > > or
> > >  ThreadContext.put("NUM", null);
> > > or
> > >  ThreadContext.put("NUM", "");
> > >
> > > Every time I get
> > > Caused by: org.apache.derby.client.am.SqlException: Error for batch
> > element
> > > #0: Invalid character string format for type BIGINT.
> > >    at org.apache.derby.client.am.Statement.completeExecute(Unknown
> > Source)
> > >
> > > I believe this is because, in
> > >
> >
> org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.writeInternal()
> > > we always do
> > >  this.statement.setString(i++, column.layout.toSerializable(event));
> > >
> > > So we always end up feeding the String "" or "NULL" to the statement.
> > >
> > > Is there anything I can do to alter this behavior?
> > >
> > > Thanks
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>



-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to