null pointr excep in preparedStatement.setBinaryStream(5,is,file.length())

Hi

I am getting null pointer exception when i try to update a blob using preparedStatement.setBinaryStream(5,is,file.length())

Please note that the preparedstatement is not null

the inputstream and the file is also not null

Infact i am able to buffer this stream..However when i do setBinaryStream, i am getting null pointer exception.

Please help

Thanks

[397 byte] By [Sid888a] at [2007-11-27 3:33:30]
# 1
Where exactly does this nullpointerexception come from? Do a sysout of preparedStatement, is and file.length() before.You may try to use is.available() instead of file.length(). You can also try PreparedStatement#setBytes() instead of setBinaryStream().
BalusCa at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi I have to update a Blob object and setBinaryStream is the best way to do it. Neither the filestream object or the file.length is null.I am getting proper values for all these . Only when i do the operation, setBinaryStream, I am getting nullpointer exception
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Which DB exactly and which JDBC driver exactly? Provide name as well as version.
BalusCa at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Did you insert an empty blob in there before trying to set the stream? Many examples I have seen to do this always insert an empty blob before setting the actual byte values in there.
kdajania at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Hi BalusOracle version is 9i (9.2.0.4) to be precise. Can you please let me know how i can find the JDBC version? Sorry for the troubleThanksSid
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi BalusI got my JDBC version as well. It is 8.1.7.0.0 and my oracle is 9I. Would this cause an issue?Please replyThanksSid
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
HiCan anybody help me with this? I am getting nullpointer exception when i try to do preparedstatement.setBinaryStreamMyJDBC version as well. It is 8.1.7.0.0 and my oracle is 9I. JDK is 1.6ThanksSid
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

That's an old driver. It is not supported in there. Use setBLOB instead.

Also see:

http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/datacc.htm

http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oralob.htm#1043272

I am not sure if a driver upgrade would help, I don't have much experience with Oracle stuff. But you now know the cause at least :)

BalusCa at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
HiI updated the driver to 9i but still getting this error when i do preparedStatement.setBinaryStream. Any ideas?Caused by: java.lang.AbstractMethodError: org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setBlob(ILjava/io/InputStream;)V
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
Hi Problem has been resolved. Full Marks to BalusC!!!..Thank you sir!!!Sid
Sid888a at 2007-7-12 8:36:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...