Claus,

If you use a StringBuffer instead of a String to copy the bytes into, you won't
be allocating/deallocating as much memory.

Jeff Hubbach

Claus Ibsen wrote:

> Hi
>
> We use this util method to get a clob field:
> ejb: weblogic 5.1 at this time, but evaluating orionserver at the moment
> oracle: 8.1.6i
>
> code
> ====
>    /**
>     * Converts a <code>Clob</code> object to a String. <br>
>     * <p>
>     *
>     * Note: If there is a problem converting null is returned.
>     *
>     *@param clob  the clob field to get as string
>     *@return      the string
>     */
>    public String getStringFromClob(Clob clob) {
>       String ss = "";
>       try {
>          byte b = (byte) ' ';
>          int len = (int) clob.length();
>          InputStream inp = clob.getAsciiStream();
>
>          for (int i = 0; i < len; i++) {
>             b = (byte) inp.read();
>             ss += (char) b;
>          }
>       } catch (SQLException e) {
>          return "";
>       } catch (IOException e) {
>          return "";
>       } catch (NullPointerException e) {
>          return "";
>       }
>
>       return ss;
>    }
>
> Regards
>
> Claus Ibsen
> Programmer at www.travelmarket.com
>
> -----Original Message-----
> From: Tim Squires [mailto:[EMAIL PROTECTED]]
> Sent: 27. marts 2001 10:54
> To: Orion-Interest
> Subject: Oracle Clob Prob
>
> Hi,
>
> I'm having problems pulling a clob out of Oracle 8.1.7 into an entity ejb:
>
> When I declare the container managed field as a string (it's a clob in the
> db), the field is always null.
> When I declare the field as oracle.sql.CLOB and access the contents, the
> following error is thrown:
> java.lang.NullPointerException at
> java.io.ObjectInputStream.readFullyInternal(ObjectInputStream.java:1780) at
> java.io.ObjectInputStream.bufferData(ObjectInputStream.java:1750) at
> java.io.ObjectInputStream.readShort(ObjectInputStream.java:1935) at
> java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:842) at
> java.io.ObjectInputStream.(ObjectInputStream.java:168) at
> com.evermind.io.kq.(JAX) at com.evermind.server.ejb.gw.(JAX) at
> com.evermind.server.ejb.EntityEJBObject.deSerialize(JAX) at
> Knowledge_Content_EntityBeanWrapper44.loadState(Knowledge_Content_EntityBean
> Wrapper44.java:1027) at
> Knowledge_Content_EntityBeanWrapper44.getContent(Knowledge_Content_EntityBea
> nWrapper44.java:222) at
> __jspPage2_test_jsp._jspService(__jspPage2_test_jsp.java:63) at
> com.orionserver.http.OrionHttpJspPage.service(JAX) at
> com.evermind.server.http.HttpApplication.xu(JAX) at
> com.evermind.server.http.JSPServlet.service(JAX) at
> com.evermind.server.http.d4.s3(JAX) at com.evermind.server.http.d4.s1(JAX)
> at com.evermind.server.http.eg.s9(JAX) at
> com.evermind.server.http.eg.dr(JAX) at com.evermind.util.f.run(JAX)
>
> When I declare the field as java.sql.Clob, it throws this exception:
> com.evermind.server.rmi.OrionRemoteException: java.lang.NullPointerException
> at com.evermind.server.ejb.EJBUtils.getUserException(JAX) at
> Knowledge_Content_EntityBeanWrapper44.getContent(Knowledge_Content_EntityBea
> nWrapper44.java:273) at
> __jspPage0_test_jsp._jspService(__jspPage0_test_jsp.java:63) at
> com.orionserver.http.OrionHttpJspPage.service(JAX) at
> com.evermind.server.http.HttpApplication.xu(JAX) at
> com.evermind.server.http.JSPServlet.service(JAX) at
> com.evermind.server.http.d4.s3(JAX) at com.evermind.server.http.d4.s1(JAX)
> at com.evermind.server.http.eg.s9(JAX) at
> com.evermind.server.http.eg.dr(JAX) at com.evermind.util.f.run(JAX)
>
> All the errors are thrown when I access the getContent method of the remote
> interface even if I just return a test string.
>
> Any help would be appreciated,
> Tim.

--
Jeff Hubbach
Internet Developer
New Media Designs, Inc.
www.nmd.com




Reply via email to