can't read clob [message #91845] |
Mon, 14 April 2003 01:27 |
zbcong
Messages: 3 Registered: December 2002
|
Junior Member |
|
|
hello
see my code snippet:
String sql=.....................
Statement stmt = conn.createStatement();
OracleResultSet rs = (OracleResultSet) stmt.executeQuery(sql);
while (rs.next()) {
CLOB clob = rs.getCLOB("QuartReq");
Reader rd = clob.getCharacterStream();
int nchars = clob.getBufferSize();
System.out.println(nchars);
char[[]] buffer = new char[[nchars]];
length=rd.read(buffer);
}
when the last line is executed,the following exception is thrown:
java.io.IOException: ?#131;~{B'~}?#130;~{B1~}?#130;~{B;~}?#131;~{B%~}?#130;?#158;?#130;?#139;?#131;~{B)~}?#130;?#149;?#130;~{B?~}?#131;~{B%~}?#130;~{B:~}?#130;~{B&~}?#131;~{B%~}?#130;~{B$~}?#130;~{B'~}?#131;~{B$~}?#130;~{B:~}?#130;?#142;?#131;~{B&~}?#130;?#156;?#130;?#128;?#131;~{B%~}?#130;~{B$~}?#130;~{B'~}?#131;~{B%~}?#130;?#128;?#130;~{B<~}
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:716)
at oracle.jdbc.driver.OracleClobReader.needChars(OracleClobReader.java:222)
at oracle.jdbc.driver.OracleClobReader.read(OracleClobReader.java:163)
at java.io.Reader.read(Reader.java:100)
at testclob.ViewClob.doGet(ViewClob.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:280)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:553)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1717)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:549)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1667)
at org.mortbay.http.HttpServer.service(HttpServer.java:862)
at org.jboss.jetty.Jetty.service(Jetty.java:497)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:759)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:923)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:776)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:202)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
............
.............
it is in chinese,mean that the "type length larger then the maximum value".
thank you!
|
|
|
Re: can't read clob [message #91853 is a reply to message #91845] |
Thu, 08 May 2003 08:48 |
Roye Avidor
Messages: 2 Registered: May 2003
|
Junior Member |
|
|
I would replace the line :
clob.getBufferSize();
with
clob.length();
you want to know the length of the string in the CLOB, not the size of its buffer.
|
|
|