db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r408863 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
Date Tue, 23 May 2006 09:57:06 GMT
Author: arminw
Date: Tue May 23 02:57:06 2006
New Revision: 408863

URL: http://svn.apache.org/viewvc?rev=408863&view=rev
Log:
fix JDK1.3 compatibility issue

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java?rev=408863&r1=408862&r2=408863&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
Tue May 23 02:57:06 2006
@@ -333,7 +333,7 @@
                 }
                 ps.setBinaryStream(index, b.getBinaryStream(), length);
             }
-            else if(locatorsUpdateCopy(ps.getConnection()))
+            else if(detectLocatorsUpdateState(ps))
             {
                 ps.setBlob(index, b);
             }
@@ -379,7 +379,7 @@
                 }
                 ps.setCharacterStream(index, c.getCharacterStream(), length);
             }
-            else if(locatorsUpdateCopy(ps.getConnection()))
+            else if(detectLocatorsUpdateState(ps))
             {
                 ps.setClob(index, c);
             }
@@ -584,6 +584,32 @@
     }
 
     /**
+     * Return the state of locator object update state and add workaround for
+     * problem with statement pooling with common-dbcp.
+     */
+    protected boolean detectLocatorsUpdateState(Statement stmt) throws SQLException
+    {
+        // TODO: Fix this, add broker instance on Platform method calls
+        Connection con = stmt.getConnection();
+        if(con == null)
+        {
+            /*
+            arminw: workaround for problem with statement pooling and faulty implementation
of method
+            Statement.getConnection()
+            */
+            log.warn("Can't detect LOB locators update state from connection metadata, specified
connection" +
+                    " instance is 'null', e.g. this can be a statement pooling problem when
OJB use method" +
+                    " Statement.getConnection() and current Connection isn't reassign. Will
use default" +
+                    " setting this time.");
+            return true;
+        }
+        else
+        {
+            return locatorsUpdateCopy(con);
+        }
+    }
+
+    /**
      * @see Platform#locatorsUpdateCopy(java.sql.Connection)
      */
     public boolean locatorsUpdateCopy(Connection con)
@@ -593,21 +619,28 @@
             /*
             TODO: Seems we have to override this method in each Platform Impl for proper
JDK1.3 support
             */
+
+//#ifdef JDBC30
+
             try
             {
-//#ifdef JDBC30
+
                 locatorsUpdateCopy = con.getMetaData().locatorsUpdateCopy() ? Boolean.TRUE
: Boolean.FALSE;
-//#else
-/*
-                locatorsUpdateCopy = Boolean.TRUE;
-*/
-//#endif
             }
             catch(SQLException e)
             {
                 log.error("Can't detect LOB locators support type, use default setting" ,
e);
                 locatorsUpdateCopy = Boolean.TRUE;
             }
+
+//#else
+
+/*
+                locatorsUpdateCopy = Boolean.TRUE;
+*/
+
+//#endif
+
         }
         return locatorsUpdateCopy.booleanValue();
     }



---------------------------------------------------------------------
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