You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2007/07/12 16:03:28 UTC
DO NOT REPLY [Bug 42870] New: - DBAppender omits RETURN_GENERATED_KEYS, NullPointerException
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42870>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42870
Summary: DBAppender omits RETURN_GENERATED_KEYS,
NullPointerException
Product: Log4j
Version: 1.3alpha
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Appender
AssignedTo: log4j-dev@logging.apache.org
ReportedBy: richard.landers@ct.gov
DBAppender.append(..) calls prepareStatement(..) without specifying the
Statement.RETURN_GENERATED_KEYS flag, even when the connection is known to
support the method getGeneratedKeys().
On DB2 v9 with JDBC type 4 driver (com.ibm.db2.jcc.DB2Driver) at least, this
causes a NullPointerException later on when DBAppender tries to read the
generated key. When the flag is not specified, the ResultSet returned from
getGeneratedKeys() is null. NPE at DBAppender.java line 267.
Existing bug: 37349 "DBAppender not working with jTDS driver" seems to have the
same root cause.
Here's a code snippet that fixes the problem for me:
protected void append(LoggingEvent event) {
Connection connection = null;
try {
connection = connectionSource.getConnection();
connection.setAutoCommit(false);
PreparedStatement insertStatement;
if (cnxSupportsGetGeneratedKeys) {
insertStatement = connection.prepareStatement(
insertSQL, Statement.RETURN_GENERATED_KEYS);
} else {
insertStatement = connection.prepareStatement(insertSQL);
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
DO NOT REPLY [Bug 42870] - DBAppender omits RETURN_GENERATED_KEYS, NullPointerException
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42870>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42870
sdeboy@iname.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From sdeboy@iname.com 2007-08-09 23:17 -------
Implemented in revision 564479
http://svn.apache.org/viewvc?view=rev&revision=564479
Thanks
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org