Bob,
 
This won't work. It may for a day or so, but the server will soon choke under heavy load. You need to have the finally also close the statement, the result set, AND the connection.
 
Also, you need to take care with the update, because clobs will need a new empty clob in the column or the old and new text will mix. You not doing that in your code.
 
Go to www.elephantwalker.com , join if you haven't (its free). Go to this request:
 
http://www.elephantwalker.com/rfa?id=86
 
 
 
 
It has a stateless session bean and some oracle dao (the facade/dao pattern) which you can download...just click on the files. The code is bullet proof and tested with many large strings (we tested it with over 20,000 messages, all over 30k) ...and is used to power the messages on the site.  We use the slsb with a cmp/ejb for our messages...it saved us a lot of time and effort on developing our forum application.
 
The oracle otn stuff is a good start, but leaves out the finally and the update issues. These are well known omissions in the oracle documentation (check out the jdbc forum).
 
regards,
 
the elephantwalker
www.elephantwalker.com
 
 
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Robert S. Sfeir
Sent: Friday, September 14, 2001 2:39 PM
To: Orion-Interest
Subject: Re: Oracle questions (Slightly OT)

You can't insert large data into Oracle directly.  If you want to use a CLOB to store your large amount of data you CAN do it with a bean, but you have to use some of the procedures imbeded in Oracle to deal with LOB data.  An example would be something like this:

public int insertClob( int idColumn, String clobData )
    throws SQLException
    {
        Connection conn = getConnection();
        try
        {
            // insert empty CLOB
            String theSql = "INSERT INTO theTable (id, clobColumn) VALUES (" + idColumn + ", EMPTY_CLOB())";
            Statement stmt = conn.createStatement();
            stmt.executeUpdate( theSql );

            // get CLOB locator
            theSql = "SELECT clobColumn FROM  theTable WHERE id  = " + idColumn + " FOR UPDATE";
            OracleResultSet rs = (OracleResultSet)stmt.executeQuery( theSql );
            rs.next();
            CLOB clob = rs.getCLOB( 1 );
            clob.putChars( 1, clobData.toCharArray() );

            // cleanup
            clob = null;
            rs.close();
            rs = null;
            stmt.close();
            stmt = null;
        }
        finally
        {
            returnConnection();
        }
        return 1;
    }

Gregory Scott wrote:
[EMAIL PROTECTED]" type="cite">




You can also look at the 8.1.7 online docs for java examples or now the 9i online docs.  Sign up with Otn.oracle.com, and get a free account, get tons of examples.

If you are always going to use an Oracle database, then optimal performance will come from  the thick driver. However, the thin driver is the most frequently used.




>From: "The elephantwalker" >Reply-To: Orion-Interest >To: Orion-Interest >Subject: RE: Oracle questions (Slightly OT) >Date: Thu, 13 Sep 2001 09:27:28 -0700 > >You will have to use clob's to store large strings in oracle. > >Go to www.elephantwalker.com and login. If you don't have an account, create >one...its free. > >Go to this request http://www.elephantwalker.com/rfa?id=86 > >There you can download a stateless session bean and oracle dao to store >large strings in oracle. A version of this bean is used on the site, and we >have tested it with EXTREMELY large strings. > >I would not use any odbc bridge to do this....a real waste of time. > >Regards, > >the elephantwalker > > > > >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED]]On Behalf Of Lachezar >Dobrev >Sent: Thursday, September 13, 2001 8:51 AM >To: Orion-Interest >Subject: Oracle questions (Slightly OT) > > > Hello group. > I have urgent need of advise. > I use an Oracle DB. And I have problems. > > 1. When using a ThinDriver I can not save large strings, and it is a must >for me. > 2. When using Oracle-Odbc-Jdbc-Ejb I can save the large strings, but... >Orion gets a lot of SQL exceptions, because of 'invalid character'. My >research shows, that while Oracle uses a DOT to express float numbers >(123.456) the jdbc-odbc bridge happens to use the COMMA for the delimiter, >because of my LOCAL settings. Then it just blows up steam. > > So. My question is like is there any non-ODBC-using driver for Oracle, >that can handle large strings? > > I'm in an urgent need for help, because the LOCAL settings change is not >an option. > > Please any advice. PLEASE! > > Lachezar > > > >


Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to