You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jonathan Beer <jb...@texadasoftware.com> on 2006/03/14 17:33:25 UTC

DBAppender + MSSQL

Hello,

I am using log4j v1.3alpha-8.

I am attempting to use a DBAppender to append to a MsSQL database (2005
Express).

#1) The MsSQL driver from Microsoft (sqljdbc.jar -
com.microsoft.sqlserver.jdbc.SQLServerDriver) doesn't work with the
DBAppender. Theoretically, it supports the getGeneratedKeys method.  I have
traced the code execution, and I see it running the getGeneratedKeys method
after having invoked the SQL statement. But it returns the following error:

"Exception: java.lang.reflect.InvocationTargetException: The statement must
be executed before the generated keys are available"
Line # 243 of DBAppender
This occurs when invoking getGeneratedKeys method on java.sql.Statement
interface

As MS doesn't provide source, I don't know a solution to this.


#2) The iTDS driver for MsSQL also doesn't work properly. After tracing
through the code, it also supports the getGeneratedKeys method... sort of.
They have provided an implementation of getGeneratedKeys that simply returns
a dummy resultset. I'm not sure there's anything that can be done about this
until their implementation is fixed, aside from removing the dependency on
"getGeneratedKeys", which seems like it would take a lot of refactoring.

Exception: java.sql.SQLException: No current row in the ResultSet. 
Line# 268 of DBAppender

Explanation: DBAppender successfully invokes getGeneratedKeys method on the
Statement implementation class, but fail to get the actual generated value
from the resultset, cause it seems the returned resultset is a fake (empty)
one (according to the sources comments in JtdsStatement class).  I appended
my findings to the existing bug report on this issue.

If anybody is using MSSQL + DBAPPENDER, I would love to hear from you, and
how you have done it.

In the meantime, I have switched to using MySQL, and it works without a
problem.

Thanks,
Jonathan



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