Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Aurora bug with DataInput.readFully ?
Hi Emmanuel,
Try making the following code changes:
byte raw[] = new byte[32767];
to
byte raw[] = new byte[4*1024]; // Becuase I know 4* works, you can change the 4 to something bigger, but
// it's vm/driverdependent. As you've found 32767 seems to be Aurora's limit
// Change the single read:
dis.readFully(raw);
// to a loop
int bytesRead;
while (bytesRead = dis.read(raw) != -1) {
// Do something with the buffer raw. }
Hope that helps.
cindy
Emmanuel BOURG wrote:
> Hello,
>
> I have a Java stored function that use the readFully method from the
> class DataInputStream to fetch a long row of 5Mb. However it seems that
> Aurora can't handle readFully for arrays larger than 32767 (2^15-1). In
> the following example, if I change the length of raw[] to 32768, i get
> an EOFException :
>
> java.io.EOFException
> at java.io.DataInputStream.readFully(DataInputStream.java)
> at java.io.DataInputStream.readFully(DataInputStream.java)
> at rftest.readFullyTest(rftest:22)
>
> The same program, when running outside Oracle, works correctly. So i
> suppose this is a bug in the Oracle JavaVM.
>
> Has anyone an idea to fetch more than 32k data ?
>
> Emmanuel BOURG
>
> ---------------------------------------------------------------------
>
> import java.io.*;
> import java.sql.*;
> import oracle.jdbc.driver.*;
>
> public class rftest
> {
> public static int readFullyTest() throws SQLException
> {
> Connection con = null;
> Statement stmt;
>
> byte raw[] = new byte[32767];
>
> con = new OracleDriver().defaultConnection();
> stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("SELECT bin FROM data WHERE
> id=1");
> rs.next();
>
> try
> {
> DataInputStream dis = new
> DataInputStream(rs.getBinaryStream(1));
> dis.readFully(raw);
> dis.close();
> stmt.close();
> }
> catch (IOException e) { System.err.println(e.getMessage());
> e.printStackTrace(); }
>
> return 1;
> }
> }
Received on Wed Aug 18 1999 - 11:55:17 CDT