Re: Will Connection.createBlob be implemented any time soon?

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема Re: Will Connection.createBlob be implemented any time soon?
Дата
Msg-id OfficeNetEmail.42.f72b9f7033d07cda.143aaba04c0@prod2
обсуждение исходный текст
Ответ на Re: Will Connection.createBlob be implemented any time soon?  (Thomas Kellerer <spam_eater@gmx.net>)
Ответы Re: Will Connection.createBlob be implemented any time soon?  (Thomas Kellerer <spam_eater@gmx.net>)
Re: Will Connection.createBlob be implemented any time soon?  (Tom Dunstan <pgsql@tomd.cc>)
Список pgsql-jdbc
På søndag 19. januar 2014 kl. 14:31:00, skrev Thomas Kellerer <spam_eater@gmx.net>:
Andreas Joseph Krogh wrote on 19.01.2014 14:14:
> $subject
> It'd be nice to be able to do:
>                  val b = con.createBlob()
>                  val os = b.setBinaryStream(1)
>                  IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
> Is there a work-around for it?

Using PreparedStatement.setBinaryStream() works without problems.
You don't even need the intermediate Blob instance:

PreparedStatement pstmt = con.createStatement("....");

pstmt.setBinaryStream(1, is);
   or
pstmt.setBinaryStream(1, is, length);  // if the length is known
 
I'm using JPA and need to be able to set a (new) Blob as a field, like this:
 
                val b = con.createBlob()
                val os = b.setBinaryStream(1)
                IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
                myEntity.setData(b)
 
Where MyEntity has a field "data" which is of type "Blob"
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Will Connection.createBlob be implemented any time soon?
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Will Connection.createBlob be implemented any time soon?