db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilkka Priha <ipr...@norther.org>
Subject Patch to validation query
Date Thu, 27 Oct 2005 14:00:19 GMT
Hi,

Handling of PreparedStatement during connection validation is invalid. 
The fetch size is set first, but javadoc specifies that 
PreparedStatement.setFetchSize(rows) may throw an exception if

0 <= rows <= this.getMaxRows()

Now, zero is the default for PreparedStatement.getMaxRows() and although 
  its meaning is an unlimited number of rows, Sun's JDBC/ODBC driver 
takes the spec literally and throws an exception when the fetch size is 
set above zero without first setting the max rows to at least the same 
size. So changing the order of the fetch size and max rows settings 
fixes the query.

-- Ilkka


Index: ConnectionFactoryPooledImpl.java
===================================================================
RCS file: 
/home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java,v
retrieving revision 1.15.2.8
diff -u -r1.15.2.8 ConnectionFactoryPooledImpl.java
--- ConnectionFactoryPooledImpl.java    9 Oct 2005 23:51:01 -0000 
1.15.2.8
+++ ConnectionFactoryPooledImpl.java    27 Oct 2005 13:35:38 -0000
@@ -224,8 +224,8 @@
              try
              {
                  stmt = conn.prepareStatement(query);
-                stmt.setFetchSize(1);
                  stmt.setMaxRows(1);
+                stmt.setFetchSize(1);
                  rset = stmt.executeQuery();
                  if (rset.next())
                  {


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message