Starting point of setBinaryStream(long pos) on java.sql.Blob?

Anybody knows what I exactly have to put insetBinaryStream(long pos) method ofjava.sql.Blob?

I mean.. 0L, 1L or any?

Here comes oracle jdbc doc

--

public java.io.OutputStream getBinaryOutputStream() throws java.sql.SQLExceptionDeprecated.

This method is deprecated. UsesetBinaryStream(0L).

And here coms another code samples in oracle documents

(http://download-west.oracle.com/docs/cd/B19306_01/java.102/b14355/oralob.htm#CHDFHHHG)

--

File binaryFile =new File("john.gif");

System.out.println("john.gif length = " + binaryFile.length());

FileInputStream instream =new FileInputStream(binaryFile);

OutputStream outstream = blob.setBinaryStream(1);

[883 byte] By [ticanoa] at [2007-10-2 17:50:59]
# 1
You should specify 0L to start at the beginning of the Blob
lanceaa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
hmm, looks like this needs cleaned up in the spec as getBinaryStream talks about starting at position 1.I will clarify this going forward in the spec.
lanceaa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
This will be clarified in all of the Clob/Blob methods to indicate a starting position of 1 and that a SQLException is thrown for a position < 1
lanceaa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Thanks lancea.

My instant test results that both number (0L and 1L) looks ok.

And this is what makes me crazy. (I think I'm a little bit prefer to be cleared for every :))

So. do I have to put 1L? for suer?

I found that it's explicitly 1 for OCI. (from documents)

ticanoa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Dear lancea.Are you one of who works on the SPEC?Thank you, agagin.onacit@gmail.com
ticanoa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
Yes I am the JDBC 4 spec lead
lanceaa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
I would not rely on 0L as that i suspect will stop working in the future. The intent is that the starting position is 1 and that a SQLException is thrown for a value < 1. I just updated the javadocs for JDBC 4 to clarify this .
lanceaa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
Thank you, lancea.Now, your (fast and clean) conclusion makes me free.(At least on some metal things... :)Regards.J.K. the O.
ticanoa at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

This should be documented with SO THAT IT IS VERY CLEAR FOR EVERYONE USING THE API, as it breaks the general Java contract of indexing starting from 0 and specifically the streaming contract used by java.io/java.nio classes.

So there is a semantic clash here (which in itself is a different point of argument), which I think needs to be clearly pointed out.

BR,

Joni

Joni_Niemia at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

Given the confusing nature of parameters to setBinaryStream(long), especially the fact that that the parameter should be 1L and not 0L (as expected) , could I humbly suggest that getBinaryOutputStream is retained without deprecation. The Oracle's driver code redirecting the call to setBinaryStream(long) with the correct safe value for 'long'.

This would also allow us to work with various drivers and databases between 8.0 and 10G without either recompiling code or receiving deprecation messages.

tony_eastwooda at 2007-7-13 19:09:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...