Has anybody successfully use jTDS with the DBAppender of log4j 1.3 alpha? It gave the following error: java.sql.SQLException: No current row in the ResultSet.
Do you know if it's configuration problem or a bug in jTDS? By the way, I tried with the inet driver and it works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"No current row in ResultSet" means that a read/update/delete was attempted while the position in the result set was either before the first row or after the last. This is not a jTDS bug, but probably an issue of DBAppender.
Please post a complete stack trace. ALWAYS. Otherwise all you'll get are suppositions.
Alin.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
java.sql.SQLException: No current row in the ResultSet.
at net.sourceforge.jtds.jdbc.JtdsResultSet.getColumn(JtdsResultSet.java:269)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getInt(JtdsResultSet.java:630)
at org.apache.log4j.db.DBAppender.append(DBAppender.java:226)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:239)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:67)
at org.apache.log4j.Category.callAppenders(Category.java:219)
at org.apache.log4j.Category.forcedLog(Category.java:588)
at org.apache.log4j.Category.log(Category.java:1169)
at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:135)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A (less important) warning first: looking at the stack trace your version of jTDS is 1.0.3, not 1.1 as you stated in your initial post. Search your classpath for older versions of jTDS lying around.
Moving on to the error itself it's indeed caused by DBAppender. It tries to retrieve auto generated keys although it didn't request them in the first place: it calls prepareStatement(String) instead of prepareStatement(String, int), which is needed if auto generated keys are to be retrieved. A second problem is that it doesn't even check whether ResultSet.next() returned true or not and it just goes for the value which isn't there. Here's the code in question:
Has anybody successfully use jTDS with the DBAppender of log4j 1.3 alpha? It gave the following error: java.sql.SQLException: No current row in the ResultSet.
Do you know if it's configuration problem or a bug in jTDS? By the way, I tried with the inet driver and it works.
Thanks. I've reported the bug to log4j bugzilla.
I changed to jTDS 1.0.3 to test if it's a new bug generated by 1.1 but forgot to change it back.
Greatly appreciated for the help.
"No current row in ResultSet" means that a read/update/delete was attempted while the position in the result set was either before the first row or after the last. This is not a jTDS bug, but probably an issue of DBAppender.
Please post a complete stack trace. ALWAYS. Otherwise all you'll get are suppositions.
Alin.
Here is the stack trace, using jTDS 1.1:
java.sql.SQLException: No current row in the ResultSet.
at net.sourceforge.jtds.jdbc.JtdsResultSet.getColumn(JtdsResultSet.java:269)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getInt(JtdsResultSet.java:630)
at org.apache.log4j.db.DBAppender.append(DBAppender.java:226)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:239)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:67)
at org.apache.log4j.Category.callAppenders(Category.java:219)
at org.apache.log4j.Category.forcedLog(Category.java:588)
at org.apache.log4j.Category.log(Category.java:1169)
at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:135)
A (less important) warning first: looking at the stack trace your version of jTDS is 1.0.3, not 1.1 as you stated in your initial post. Search your classpath for older versions of jTDS lying around.
Moving on to the error itself it's indeed caused by DBAppender. It tries to retrieve auto generated keys although it didn't request them in the first place: it calls prepareStatement(String) instead of prepareStatement(String, int), which is needed if auto generated keys are to be retrieved. A second problem is that it doesn't even check whether ResultSet.next() returned true or not and it just goes for the value which isn't there. Here's the code in question:
http://fisheye.cenqua.com/viewrep/jakarta/jakarta-log4j/src/java/org/apache/log4j/db/DBAppender.java?r=1.17&k=
Please submit a bug report to the log4j developers about this issue.
Alin.