• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error while updating image data in database  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have table where datatype of a column is CLOB.
String query = "update tablename set image=?'";
PreparedStatement st1=conn.prepareStatement(query);
st1.setBlob(1,new DataInputStream(myImg));
int retVal = st1.executeUpdate();

I am getting following error:
root cause

javax.servlet.ServletException: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CPreparedStatement.setBlob(ILjava/io/InputStream;)V

Thanks for your help!
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We'll need a little more information than that.

Also, I noticed three quotes ''' in your prepared statement. Is that by design or a typo error?

Rudra Nath
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
three quote is typo.
I was selecting an image from a JSP file like this:
<script language="javascript">
function submitPage(content){

var myImg=document.getElementById("myImg");

<form enctype="multipart/form-data" name="myForm" method="post">
String loginId = request.getParameter("loginid");

File dir = new File("C:/Tomcat/apache-tomcat-6.0.32/webapps/BeyondSmile/images/tmp/"+loginId);
File[] children = dir.listFiles();
if (children == null) {
System.out.println("tmp is blank");
// Either dir does not exist or is not a directory
} else {
StringBuffer filename =null;
StringBuffer filenameAbs =null;
InputStream is = null;
for (int i=0; i<children.length; i++) {
filename =new StringBuffer();
filenameAbs =new StringBuffer();
is= new FileInputStream(filenameAbs.toString());
<input type="image" id="myImg" src="<%= filename.toString()%>" height="100" width="100" onclick="javascript:submitPage('myImg=<%= is %>');">
<input type="hidden" name="myImg" value='<%=is %>'>

Here I am seding image as hidden parameter.
In next JSP page, I am retriving it like this:
InputStream myImg = (InputStream)request.getSession().getAttribute("myImg");
and it is not null.
then I am trying to update it in database (Oracle 10g)
Posts: 21208
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setBlob(int, InputStream) was only added in Java 6. Your JDBC driver probably is out of date. Check if there's an updated version.

If there isn't, you have a few choices. One is to use setBinaryStream(int, InputStream, int), but you have to know the number of bytes that will be stored. If you don't know that, copy the contents of the InputStream to a ByteArrayOutputStream, get its data (toByteArray()) and use that with setBytes(int, byte[]).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!