Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30443

Re: jdbc setBinaryStream

From Daniele Futtorovic <da.futt.news@laposte.net>
Newsgroups comp.lang.java.programmer
Subject Re: jdbc setBinaryStream
Date 2014-11-29 16:57 +0100
Organization A noiseless patient Spider
Message-ID <m5cqds$t9c$1@dont-email.me> (permalink)
References <slrnm7jn16.uoi.avl@login.logic.tuwien.ac.at>

Show all headers | View raw


On 2014-11-29 15:45, Andreas Leitgeb wrote:
> What I need is like
>    insert into sometable values ( 0, ? )
> where the relevant column is a varlongbinary (not blob) and
> it is fed from an external data source accessed through a 
> custom InputStream.
> 
> I create a PreparedStatement "prep" for the query and:
>    InputStream source = ... (some custom InputStream)
>    prep.setBinaryStream(1, source ); // the one with no length
> 
> 
> Problem is, it ignores my stream altogether. Eclipse breakpoints on
> read methods never trigger. It just silently inserts an empty object.
> 
> 
> My custom InputStream implements the no-arg read() and the three-arg
> read(arr,off,len). The one-arg read(arr) falls back to the three-args
> one by base class's implementation.
> 
> The overload of setBinaryStream without a length parameter is new
> in jdbc 4.0, and I read from the docs that it should mean: get as many
> bytes as possible from that stream (i.e. until EOF).
> Obviously that is not always so - at least not with the informix
> server I'm targetting or with the ifxjdbc.jar I got from the server's
> jdbc/lib folder.
> 
> Has anyone else run into that problem and perhaps found a solution?
> 
> PS: the only relevant google hit is an unanswered stackoverflow question
>   http://stackoverflow.com/questions/20471030/setbinarystream-saves-null-values
> and that was even for a different db-system than the one I'm targetting.
> 

Have you made sure your InputStream is behaving as you assume it does?

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-29 14:45 +0000
  Re: jdbc setBinaryStream Daniele Futtorovic <da.futt.news@laposte.net> - 2014-11-29 16:57 +0100
    Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-29 16:58 +0000
      Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-29 19:39 +0000
        Re: jdbc setBinaryStream Daniele Futtorovic <da.futt.news@laposte.net> - 2014-11-30 02:37 +0100
          Re: jdbc setBinaryStream Arne Vajhøj <arne@vajhoej.dk> - 2014-11-29 21:26 -0500
            Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-30 11:12 +0000
  Re: jdbc setBinaryStream Martin Gregorie <martin@address-in-sig.invalid> - 2014-11-29 19:59 +0000
    Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-29 20:36 +0000
      Re: jdbc setBinaryStream Martin Gregorie <martin@address-in-sig.invalid> - 2014-11-30 00:07 +0000
        Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-11-30 14:56 +0000
          Re: jdbc setBinaryStream Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-01 14:06 +0000
            Re: jdbc setBinaryStream Arne Vajhøj <arne@vajhoej.dk> - 2014-12-01 21:36 -0500
              Re: jdbc setBinaryStream Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-02 12:16 +0000
            Re: jdbc setBinaryStream Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-12-02 17:56 +0000
              Re: jdbc setBinaryStream Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-02 21:37 +0000

csiph-web