logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Betty User <usrbe...@gmail.com>
Subject Re: Log4j 2 - Not implemented method used in JDBC appender
Date Tue, 16 Jul 2013 13:24:59 GMT
Hi Nick,

agreed, this issue is related to poor implementation of PostgreSQL
JDBC 4. Unfortunately there is no way how to change PostgreSQL to
another database.

I tried it and it works with isUnicode="false". But event logs are in
unicode, shouldn't be there some problem during saving unicode events
messages with disabled unicode support?

M.

2013/7/16 Nick Williams <nicholas@nicholaswilliams.net>:
> Actually I need to correct myself:
>
> On Jul 16, 2013, at 7:57 AM, Nick Williams wrote:
>
>> M.,
>>
>> setNString() is part of JDBC 4.0, which came with Java 6. It sounds like you are
using the postgresql-x.x-xxxx.jdbc3.jar JDBC driver, which was written for Java 4. Please
download the latest JDBC driver postgresql-9.2-1003.jdbc4.jar (http://jdbc.postgresql.org/download/postgresql-9.2-1003.jdbc4.jar).
However, you should note that PostgreSQL's website says the following:
>>
>>> Support for JDBC4 methods is not complete, but the majority of methods are implemented.
>>
>> So it's possible that even the latest driver is not fully JDBC 4.0 compliant and
won't support this method. In that case, there's nothing we can do about it.
>
> There is something you can do about it: don't use unicode columns. Look at the documentation
for the JDBC Appender (http://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender)
and scroll down to the "Column Parameters" table. Each String <Column> you define defaults
to unicode (because unicode is the best way for storing Java unicode Strings). If you use
the defaults (all String columns are unicode) then the database columns for your table must
be NVARCHAR (not VARCHAR) and Log4j will use setNString. However, if you add isUnicode="false"
to the String columns, Log4j will use setString (and your database columns must be VARCHAR,
not NVARCHAR).
>
> To be clear, it's really best and most efficient to store these values unicode. However,
if the latest PostgreSQL driver still does not support setNString (again, this is a "bad thing"),
you can use isUnicode="false" to get around this.
>
>> PostgreSQL has had 7 years to implement a JDBC 4.0 driver; you'll need to complain
to them. JDBC 4.1 came out two years ago and JDBC 4.2 comes out next March. I suppose it'll
be ~2020 before they implement those. :-/
>>
>> Opinion Section: Based on my reading of PostgreSQL website, it doesn't sound like
a very Java-friendly database to use if you want to use modern versions of Java. At least
MySQL and Microsoft SQL Server support JDBC 4.0 (which Log4j requires) though they still haven't
implemented JDBC 4.1 (which Log4j does not require). Only Oracle fully supports JDBC 4.1 right
now (sad face).
>>
>> Nick
>>
>> On Jul 16, 2013, at 6:18 AM, Betty User wrote:
>>
>>> Hello,
>>>
>>> I am trying to log Log4j 2 events into PostgreSQL database via JDBC
>>> appender with datasource (com.jolbox.bonecp.BoneCPDataSource).
>>>
>>> This data source uses JDBC driver for PostgreSQL
>>> (postgresql-9.2-1003.jdbc4.jar) but there isn't implemented
>>> method org.postgresql.jdbc4.Jdbc4PreparedStatement.setNString(int, String)
>>> which is called from Log4j 2.
>>>
>>> Is there some another way how to use Log4J database appender with
>>> PostgreSQL database?
>>>
>>> Thank you for suggestions how to solve this issue.
>>>
>>> M.
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message