Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 81797 invoked from network); 11 Dec 2003 11:04:29 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Dec 2003 11:04:29 -0000 Received: (qmail 30633 invoked by uid 500); 11 Dec 2003 11:04:01 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 30529 invoked by uid 500); 11 Dec 2003 11:04:00 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 30515 invoked from network); 11 Dec 2003 11:03:59 -0000 Received: from unknown (HELO ns.alma.nu) (195.84.38.252) by daedalus.apache.org with SMTP; 11 Dec 2003 11:03:59 -0000 Received: from raa-se.raa.se ([193.10.40.128]) by ns.alma.nu (JAMES SMTP Server 2.1) with SMTP ID 686 for ; Thu, 11 Dec 2003 12:03:56 +0100 (CET) Message-ID: <3FD84EBE.8020206@curalia.se> Date: Thu, 11 Dec 2003 12:02:22 +0100 From: =?ISO-8859-1?Q?Martin_Kal=E9n?= Organization: Curalia AB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OJB Developers List Subject: Oracle9i platform in upcoming 1.0RC5 breaks LOB-support with oracle:thin Content-Type: multipart/mixed; boundary="------------050600090700060403060508" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --------------050600090700060403060508 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Greetings developers, the new PlatformOracle9iImpl has some very strange code for handling the flag "[GS]ET_CLOB_AND_LOB_SUPPORTED". This flag is initialized to false and the logic to enable it is embedded in flow like the following: flag = false if (otherCondition && flag is true) then check if we can set flag = true fi This results in regression if switching from OJB1.0RC4 platform=Oracle to 1.0preRC5(CVS) and platform=Oracle9i, since the code to set CLOB-data in prepared statements is something like: if (datatype is ) then process other datatypes else if (datatype is CLOB and content is String) then if (SET_CLOB_AND_LOB_SUPPORTED) then set CLOB-data in PreparedStatemend fi else pass handling on to superclass (OracleImpl) fi There are two obvious issues with this approach: 1) SET_CLOB_AND_BLOB_SUPPORTED cannot ever be set to true according to the semantics from above 2) Even if SET_CLOB_AND_BLOB_SUPPORTED is set correctly, the break-out from the main if-else-flow into "if (SET_CLOB_AND_LOB_SUPPORTED)" means a silent NO-OP fallthrough when SET_CLOB_AND_LOB_SUPPORTED=false resulting in INSERT failures since the prepared statement did not get all it's data "JdbcAccessImpl: SQLException during the execution of the insert java.sql.SQLException: ORA-01008: not all variables bound" The patch attached to this mail modifies PlatformOracle9iImpl in two ways, it: 1) fixes [GS]ET_CLOB_AND_LOB_SUPPORTED semantics so that they are set correctly 2) joins the if-conditions for CLOB and BLOB datatypes in setObjectForStatement() so that fall-through for oracle:thin is backwards compatible with OJB1.0RC4 and does not break prepared statements I couldn't find the issue in Scarab that PlatformOracle9iImpl originated from (if there was one?), so I post the patch directly to the list. Hope that's OK. The Oracle9i-specific stuff is really interesting, and it would be great if it was working for both OCI and thin in RC5/1.0. Regards, Martin -- Martin Kal�n Curalia AB Web: http://www.curalia.se Orrspelsv�gen 2B Mail: info@curalia.se SE-182 79 Stocksund Tel: +46-8-410 064 40 --------------050600090700060403060508 Content-Type: text/plain; name="oracle9i_thin_lob.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="oracle9i_thin_lob.patch" Index: src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java =================================================================== RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java,v retrieving revision 1.8 diff -u -r1.8 PlatformOracle9iImpl.java --- src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java 8 Dec 2003 10:18:16 -0000 1.8 +++ src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java 11 Dec 2003 10:14:28 -0000 @@ -101,9 +101,11 @@ private static Method SET_IMPLICIT_CACHING_ENABLED = null; private static Method SET_CLOB = null; private static Method SET_BLOB = null; - private static boolean SET_CLOB_AND_LOB_SUPPORTED = false; + private static boolean SET_CLOB_AND_BLOB_SUPPORTED = false; + private static boolean TRIED_SET_CLOB_AND_BLOB_SUPPORT = false; private static Method GET_CLOB = null; - private static boolean GET_CLOB_AND_LOB_SUPPORTED = false; + private static boolean GET_CLOB_AND_BLOB_SUPPORTED = false; + private static boolean TRIED_GET_CLOB_AND_BLOB_SUPPORT = false; private static boolean ROW_PREFETCH_SUPPORTED = true; private static Method SET_ROW_PREFETCH = null; @@ -356,17 +358,18 @@ public void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType) throws SQLException { - if (SET_CLOB == null && SET_CLOB_AND_LOB_SUPPORTED) + if (SET_CLOB == null && !TRIED_SET_CLOB_AND_BLOB_SUPPORT) { + TRIED_SET_CLOB_AND_BLOB_SUPPORT = true; try { SET_CLOB = ps.getClass().getMethod("setCLOB", new Class[]{Integer.TYPE, Class.forName("oracle.sql.CLOB")}); SET_BLOB = ps.getClass().getMethod("setBLOB", new Class[]{Integer.TYPE, Class.forName("oracle.sql.BLOB")}); - SET_CLOB_AND_LOB_SUPPORTED = true; + SET_CLOB_AND_BLOB_SUPPORTED = true; } catch (Throwable t) { - SET_CLOB_AND_LOB_SUPPORTED = false; + SET_CLOB_AND_BLOB_SUPPORTED = false; } } if (((sqlType == Types.VARBINARY) || (sqlType == Types.LONGVARBINARY)) && (value instanceof byte[])) @@ -390,48 +393,42 @@ { ps.setLong(index, ((Long) value).longValue()); } - else if (sqlType == Types.CLOB && value instanceof String) + else if (sqlType == Types.CLOB && value instanceof String && SET_CLOB_AND_BLOB_SUPPORTED) { - if (SET_CLOB_AND_LOB_SUPPORTED) + try { - try - { - SET_CLOB.invoke(ps, new Object[]{new Integer(index), Oracle9iLobHandler.createCLOBFromString(ps.getConnection(), (String) value)}); - } - catch (IllegalAccessException e) - { - throw new SQLException(e.getMessage()); - } - catch (IllegalArgumentException e) - { - throw new SQLException(e.getMessage()); - } - catch (InvocationTargetException e) - { - throw new SQLException(e.getMessage()); - } + SET_CLOB.invoke(ps, new Object[]{new Integer(index), Oracle9iLobHandler.createCLOBFromString(ps.getConnection(), (String) value)}); + } + catch (IllegalAccessException e) + { + throw new SQLException(e.getMessage()); + } + catch (IllegalArgumentException e) + { + throw new SQLException(e.getMessage()); + } + catch (InvocationTargetException e) + { + throw new SQLException(e.getMessage()); } } - else if (sqlType == Types.BLOB) + else if (sqlType == Types.BLOB && SET_CLOB_AND_BLOB_SUPPORTED) { - if (SET_CLOB_AND_LOB_SUPPORTED) + try { - try - { - SET_BLOB.invoke(ps, new Object[]{new Integer(index)}); - } - catch (IllegalAccessException e) - { - throw new SQLException(e.getMessage()); - } - catch (IllegalArgumentException e) - { - throw new SQLException(e.getMessage()); - } - catch (InvocationTargetException e) - { - throw new SQLException(e.getMessage()); - } + SET_BLOB.invoke(ps, new Object[]{new Integer(index)}); + } + catch (IllegalAccessException e) + { + throw new SQLException(e.getMessage()); + } + catch (IllegalArgumentException e) + { + throw new SQLException(e.getMessage()); + } + catch (InvocationTargetException e) + { + throw new SQLException(e.getMessage()); } } else @@ -443,19 +440,20 @@ public Object getClob(ResultSet rs, int jdbcType, String columnId) throws SQLException { String retval = ""; - if (GET_CLOB == null && GET_CLOB_AND_LOB_SUPPORTED) + if (GET_CLOB == null && !TRIED_GET_CLOB_AND_BLOB_SUPPORT) { + TRIED_GET_CLOB_AND_BLOB_SUPPORT = true; try { GET_CLOB = rs.getClass().getMethod("getCLOB", new Class[]{String.class}); - GET_CLOB_AND_LOB_SUPPORTED = true; + GET_CLOB_AND_BLOB_SUPPORTED = true; } catch (Throwable t) { - GET_CLOB_AND_LOB_SUPPORTED = false; + GET_CLOB_AND_BLOB_SUPPORTED = false; } } - if (GET_CLOB_AND_LOB_SUPPORTED) + if (GET_CLOB_AND_BLOB_SUPPORTED) { try { --------------050600090700060403060508 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org --------------050600090700060403060508--