db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Miller <smil...@vecna.com>
Subject Village Patch (Oracle Clobs)
Date Wed, 09 Apr 2003 19:11:04 GMT

I submitted a patch to the Village mailing list yesterday which allows 
Village to deal with Oracle clobs as strings.  This means that this 
patch allows Torque to properly get and set Oracle CLOBs without making 
any modifications to Torque itself.  However, since Village doesn't get 
much traffic anymore, and I do not have write access to the cvs 
repository, I am submitting my patch here as well.  I know people have 
inquired about this feature in the past and would probably like to see 
it included.  I am submitting this patch here for two reasons:

1.  Someone here may be able to help get the source updated in Village.
2.  To get a review of the changes so as to ensure that my change will 
not negatively impact Torque's ability to handle CLOBs in other databases.

The following is a cut and past from the message I sent to the Village list:

***** start cut and paste *****

I have been trying to use Torque as a database abstraction layer for an 
Oracle database containing CLOBs. However, Village does not properly 
retrieve or set CLOB values with Oracle. This is because Village uses 
the ResultSet.getString method to read the CLOB value from the database 
and the PreparedStatement.setString method to set the CLOB value. This 
approach will work for many JDBC drivers because they support the 
handling of CLOBs as Strings. However, the Oracle JDBC driver does not 
support this conversion. I have modified Value.java to properly handle 
Oracle clobs. This file is attached to this email. I am not sure of the 
proper avenue to submit a patch for Village, so I am hoping that someone 
can advise me on the best course of action. The rest of this email is 
devoted to a brief explanation of the code change.

Because Oracle's JDBC driver does not support the CLOB to String 
conversion, you need to actually use the java.sql.Clob interface, which 
is implemented by oracle.sql.CLOB. You can refer to the Clob object by 
the java.sql.Clob interface during data retrieval, because there is no 
need to instantiate an instance of the Class. The constructor of the 
Value class was modified to handle retrieval by simply adding a 
Types.CLOB case to the switch statement.

Unfortunately, you need to create an instance of the clob object when 
you want to set the CLOB data, so you must refer to the oracle.sql.CLOB 
class. However, in order to not rely on the Oracle JDBC driver at 
compile time, I have writted the code to use reflection to create an 
instance of oracle.sql.CLOB and set the value. This code is located in 
the setPreparedStatementValue method of the Value class.

Any advice on how to submit this update would be appreciated.



***** End cut and paste *****

I have attached Value.java.



View raw message