You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by mad <ma...@madworld.com> on 2002/04/01 21:01:55 UTC

Re: Oracle CLOB

> > My assumption also is, that village can't handle BLOBs/CLOBs.
> > If anyone uses these successfully, it would be of interest!
> > 
> > My solution now was mapping the Turbine-BLOB to LONG RAW in
> > db.props. As I understand it, the only difference is that BLOBs
> > can have max. 4GB, LONG RAWs only 2GB. Should be enough :)
> > Hope it really works in the long run.
> 
> Thanks Florian!  I thought about using a LONG but I need to be able to 
> use a WHERE clause against it and LONGs don't support WHERE clauses.
> 
> My next step is to look at the Village code to see if I can make it 
> support CLOBS.  

OK, here is my solution...

Download village from the CVS...

 http://share.whichever.com/index.php?SCREEN=village

To fix the NumberFormatException you must change Column.java in the method 
populate...

        this.precision = rsmd.getPrecision (columnNumber);

...replace it with...

        try {
            this.precision = rsmd.getPrecision(columnNumber);
        }catch ( NumberFormatException nfe ) {
            // This may happen if the precision is too large for an int
            // see bug #4625851 in the JDC (http://developer.java.sun.com/developer/bugParade/bugs/4625851.html)
            this.precision = Integer.MAX_VALUE;
        }        

I believe that the Village developers are making a patch for it...

http://share.whichever.com/pipermail/village-dev/2002-March/000044.html

The second problem is that Village doesn't know how to select a Clob into
a com.workingdogs.village.Value Object.  Where Value.java checks the type
I've added CLOB...

    public Value(ResultSet rs, int columnNumber, int type) throws SQLException {
	...        
        switch (type()) {
            case Types.CLOB:  //
                valueObject = readClob(rs,columnNumber);
                break;
            case Types.BIT:
                String tmp = rs.getString(columnNumber);
                ...

...and then the readClob method...

    public static String readClob(ResultSet rs, int i) throws java.sql.SQLException {
        Clob clob = (Clob)rs.getObject(i);
        BufferedReader br = new BufferedReader(clob.getCharacterStream());
        StringBuffer sb = new StringBuffer();
        String nextLine = "";
        try{
            while((nextLine = br.readLine()) != null){
                char[] ca = nextLine.toCharArray();
                sb.append(nextLine+"\n");
            }
        }catch(IOException e){
		e.printStackTrace();
        }
        
        String ColumnValue = sb.toString();
        return ColumnValue;
    }

-----------

Then build the jar to replace the village library in WEB-INF/lib and poof
it works.  I'm assuming that a BLOB would be very similar.

Hope this helps.

-mad


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>