Click here to Skip to main content
12,358,747 members (61,944 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Java Oracle
Hi all,

Am trying a sample application in java using Spring framework. The task
is to store am image into Database a byte array. For this am declaring the image field type as BLOB (in Oracle).

And in the java am executing following code to convert image to byte array.

File file = new File(path);
	        byte[] bFile = new byte[(int) file.length()];
 
	        try {
 
	        	FileInputStream fis=new FileInputStream(path);
	    		bFile = new byte[fis.available()+1];
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	        user.setImage(bFile);
			getHibernateTemplate().save(user);

where "path" is the path to the image.

But when I try to see the data in the table am getting an error saying:

ORA-00932: inconsistent datatypes: expected NUMBER got BLOB

Can you provide any suggestion or solution to solve this issue?


Thanks
Yashwanth.
Posted 5-Apr-12 18:59pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

your database expects a number (int-value) and you are delivering a blob.

Prepare your DB to be able to store a blob. The rest is fine.

http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/blob.html[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 10 Apr 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100