You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Vanessa <va...@telenet.be> on 2007/08/14 08:36:14 UTC
Problem with blob
Hello everyone
I have the next problem what I cannot solve.
I have a web application that displays blobs to the users.
I have written the code myself and when I execute it, I get an ERROR 500. java.lang.IndexOutOfBoundsException
The problem is, when I have for example 20 blobs that the users can see, al the blobs that are stock in the database with length 65000 are displayed and the one with 59056 gives the ERROR 500 java.lang.IndexOutOfBoundsException error.
This is the code I have developed for displaying the blob:
public byte[] byteread = new byte[65000];
public boolean readStudentHtml(String key) throws Exception {
try {
Etc….
If Etc… {
for Etc…. {
Object currentBlob = ((model.StudentHtml)resultList.get(i)).getAttest();
if (currentBlob != null) {
byteread = ((model.StudentHtml)resultList.get(0)).getAttest();
logger.trace("Blob found for : " + key);
return true;
} else {
logger.error("Blob not found for : " + key);
return false;
}
}
} else {
logger.error("Blob not found for : " + key);
}
} catch (Exception e) {
logger.trace("Error readStudentHtml : Cause : " + e);
e.printStackTrace();
}
return false;
}
Can someone help me.
Vanessa
Re: Problem with blob
Posted by Richard Yee <ry...@cruzio.com>.
What database are you using? What is the version of your JDBC drivers?
There are some issues with older Oracle drivers and blobs.
-Richard
Vanessa wrote:
> Hello everyone
>
> I have the next problem what I cannot solve.
> I have a web application that displays blobs to the users.
> I have written the code myself and when I execute it, I get an ERROR 500. java.lang.IndexOutOfBoundsException
> The problem is, when I have for example 20 blobs that the users can see, al the blobs that are stock in the database with length 65000 are displayed and the one with 59056 gives the ERROR 500 java.lang.IndexOutOfBoundsException error.
>
> This is the code I have developed for displaying the blob:
>
>
> public byte[] byteread = new byte[65000];
>
> public boolean readStudentHtml(String key) throws Exception {
>
> try {
> Etc….
>
> If Etc… {
> for Etc…. {
>
> Object currentBlob = ((model.StudentHtml)resultList.get(i)).getAttest();
> if (currentBlob != null) {
> byteread = ((model.StudentHtml)resultList.get(0)).getAttest();
> logger.trace("Blob found for : " + key);
> return true;
> } else {
> logger.error("Blob not found for : " + key);
> return false;
> }
> }
> } else {
> logger.error("Blob not found for : " + key);
> }
> } catch (Exception e) {
> logger.trace("Error readStudentHtml : Cause : " + e);
> e.printStackTrace();
> }
> return false;
> }
>
>
> Can someone help me.
> Vanessa
>
>
>
>
>
>
RE: Problem with blob
Posted by Meindert <me...@pastelebusiness.com>.
Hi Vanessa,
Sorry if I'm wrong (I don't work with blogs)
But I would think that the byteread object you think you set with the line
public byte[] byteread = new byte[65000];
will be overridden by
byteread = ((model.StudentHtml)resultList.get(0)).getAttest();
and a new byte array with the size 59056 would be created
I don't see in your code the place where the IndexOutOfBoundsException
would be thrown?
Kind Regards
Meindert
-----Original Message-----
From: Vanessa [mailto:vanessabossens@telenet.be]
Sent: 14 August 2007 08:36 AM
To: user-java@ibatis.apache.org
Subject: Problem with blob
Hello everyone
I have the next problem what I cannot solve.
I have a web application that displays blobs to the users.
I have written the code myself and when I execute it, I get an ERROR 500.
java.lang.IndexOutOfBoundsException
The problem is, when I have for example 20 blobs that the users can see, al
the blobs that are stock in the database with length 65000 are displayed and
the one with 59056 gives the ERROR 500 java.lang.IndexOutOfBoundsException
error.
This is the code I have developed for displaying the blob:
public byte[] byteread = new byte[65000];
public boolean readStudentHtml(String key) throws Exception {
try {
Etc..
If Etc. {
for Etc.. {
Object currentBlob =
((model.StudentHtml)resultList.get(i)).getAttest();
if (currentBlob != null) {
byteread = ((model.StudentHtml)resultList.get(0)).getAttest();
logger.trace("Blob found for : " + key);
return true;
} else {
logger.error("Blob not found for : " + key);
return false;
}
}
} else {
logger.error("Blob not found for : " + key);
}
} catch (Exception e) {
logger.trace("Error readStudentHtml : Cause : " + e);
e.printStackTrace();
}
return false;
}
Can someone help me.
Vanessa