logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Sandee <tbsan...@pobox.com>
Subject Re: Log4j JDBCAppender
Date Thu, 06 Jun 2002 15:22:43 GMT
Kevin Steppe wrote:

> Jon,
>    Please post to the users list only for this kind of question.  Now 
> to answer your question:
> try:
> sql=insert into logtable (threads) values ("%t")
> For most databases you can use either ", or ', for varchar fields.  
> Use the one not in the value.  If both are in the value you have to do 
> escaping.  As far as I can tell the JDBC version in JDK1.3.1 does not 
> have a generic escape call.  If I'm wrong, someone please tell me so I 
> can get that into the JDBCAppender.


Ideally the appender would support the optional use of PreparedStatement 
objects, rather than building SQL strings dynamically.  With a 
PreparedStatement there is no need to escape any text values.  For example:

PreparedStatement st = conn.prepareStatement("insert into logtable 
(threads) values (?)");
    st.setString(1, "I can put single quotes ' and double quotes \" in 
this text");

I believe this would take some reworking of the current JDBCAppender, 
however, due to the fact that simple text replacements cannot be used. 
 Instead there would have to be some way to associate a the integer 
parameter index with a piece of data (%t or whatever).

BTW, I don't actually use the JDBCAppender myself -- that's my 


To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message