From mail_4brad@yahoo.co.uk Tue Apr 7 13:36:43 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id DE41C63327C for ; Tue, 7 Apr 2009 10:36:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 31416-03 for ; Tue, 7 Apr 2009 10:36:27 -0300 (ADT) X-Greylist: delayed 00:06:39.974825 by SQLgrey-1.7.6 Received: from smtp118.mail.mud.yahoo.com (smtp118.mail.mud.yahoo.com [209.191.84.167]) by mail.postgresql.org (Postfix) with SMTP id BF3EA632E69 for ; Tue, 7 Apr 2009 10:36:34 -0300 (ADT) Received: (qmail 50474 invoked from network); 7 Apr 2009 13:29:52 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type; b=xZX+bGLSOaI9gYFjrTxyqSixfpbUq16A8AEbNQ99WcQKXbBzVNw7+ySCU4n3NLrDbOvJmY3agn03enNV/IGWhGVtE3+r70F0vId2CYMs4xo5YFV3/LOswpO+w0ryiwkwyclThsaP7HobNW7T3XMIZtn3Mmoj2pCf1/ft4k3OwRo= ; Received: from unknown (HELO ?192.168.1.2?) (mail_4brad@121.73.20.162 with plain) by smtp118.mail.mud.yahoo.com with SMTP; 7 Apr 2009 13:29:51 -0000 X-YMail-OSG: FqLYsV4VM1lKPz_j5jyOVux.IZdGCZKSPoIb93.gr9msmC5GGHdGM_2wk70lVXT.6A008tW3O969iRVzJvQ4aFC1Tpy7.q9G123fWJ8MEhJQPh_2O75Is6Vnuz0Afw1FSK3KyYNXeVNi8Fm_K4E1c0IY1.8s_8oP2SZUM39OiCd7GY6gm31DoBIU2lyDzr_skxwBVg422VJLaxEQaX_m.o6S0ffhriK_l_4_55i3nJV9Zakua5vseSM_jMGXsyi.DeA8k7VR5_I7ZUPnkK9zRMN9r35qhw.YFXAqRlqYUy1snysRheqW X-Yahoo-Newman-Property: ymail-3 Message-ID: <49DB559F.3030805@yahoo.co.uk> Date: Wed, 08 Apr 2009 01:31:11 +1200 From: Brad Milne User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: BLOB help - yes I've read around! Content-Type: multipart/alternative; boundary="------------030902020205010700060807" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/10 X-Sequence-Number: 19457 This is a multi-part message in MIME format. --------------030902020205010700060807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi all I'm a Java dev, new to postgres. I've just migrated an app during development from Derby to Postgres (due to better indexing features), but am very confused by the failing BLOB implementations. PostgreSQL: 8.3.7 PostgreSQL-JDBC: 8.3-604 JDK: 6 A lot of what I've seen in searches and even in the google groups page, seems to be related to older jdbc drivers, where BLOBs were supported, both for OID and bytea. I'm currently getting 'unimplemented' exceptions doing anything with BLOBs. My application saves sound files as byte arrays to the database. Q1: Given that it's sound and not text, would it be safe to use bytea given that certain characters need to be escaped? Q2: How on earth do I use the BLOB methods? In particular setBlob(int parameterIndex, InputStream inputStream) and/or createBlob() and setBlob(int parameterIndex, Blob x)? Thanks a lot Brad --------------030902020205010700060807 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all

I'm a Java dev, new to postgres. I've just migrated an app during development from Derby to Postgres (due to better indexing features), but am very confused by the failing BLOB implementations.

PostgreSQL: 8.3.7
PostgreSQL-JDBC: 8.3-604
JDK: 6

A lot of what I've seen in searches and even in the google groups page, seems to be related to older jdbc drivers, where BLOBs were supported, both for OID and bytea. I'm currently getting 'unimplemented' exceptions doing anything with BLOBs.

My application saves sound files as byte arrays to the database.

Q1: Given that it's sound and not text, would it be safe to use bytea given that certain characters need to be escaped?
Q2: How on earth do I use the BLOB methods? In particular setBlob(int parameterIndex, InputStream inputStream) and/or createBlob() and setBlob(int parameterIndex, Blob x)?

Thanks a lot
Brad
--------------030902020205010700060807-- From achill@matrix.gatewaynet.com Tue Apr 7 13:57:26 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9B50D632E69 for ; Tue, 7 Apr 2009 10:57:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99644-03 for ; Tue, 7 Apr 2009 10:57:24 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id 4E5A863280E for ; Tue, 7 Apr 2009 10:57:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mx1.hub.org (Postfix) with ESMTP id 7D319125A6C9 for ; Tue, 7 Apr 2009 10:57:21 -0300 (ADT) Received: from smadev.internal.net (localhost [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id n37Dv9JB062285; Tue, 7 Apr 2009 16:57:09 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id n37Dv8Ub062284; Tue, 7 Apr 2009 16:57:08 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-jdbc@postgresql.org Subject: Re: BLOB help - yes I've read around! Date: Tue, 7 Apr 2009 15:57:07 +0200 User-Agent: KMail/1.9.7 Cc: Brad Milne References: <49DB559F.3030805@yahoo.co.uk> In-Reply-To: <49DB559F.3030805@yahoo.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200904071657.08065.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/13 X-Sequence-Number: 19460 =CE=A3=CF=84=CE=B9=CF=82 Tuesday 07 April 2009 16:31:11 =CE=BF/=CE=B7 Brad = Milne =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > Hi all >=20 > I'm a Java dev, new to postgres. I've just migrated an app during=20 > development from Derby to Postgres (due to better indexing features),=20 > but am very confused by the failing BLOB implementations. >=20 > PostgreSQL: 8.3.7 > PostgreSQL-JDBC: 8.3-604 > JDK: 6 >=20 > A lot of what I've seen in searches and even in the google groups page,=20 > seems to be related to older jdbc drivers, where BLOBs were supported,=20 > both for OID and bytea. I'm currently getting 'unimplemented' exceptions= =20 > doing anything with BLOBs. >=20 > My application saves sound files as byte arrays to the database. >=20 > Q1: Given that it's sound and not text, would it be safe to use bytea=20 > given that certain characters need to be escaped? I have been storing binary data in bytea for ages with postgresql, with no major problems. Performance might be an issue. It is a good practice to store along with the bytea value, its mime type as well. So in your binary library you could have mp3s,oggs,mpegs, ms docs, jpegs, p= dfs, and your servlet would know exactly the content type to serve to the client. Also to answer your question about safeness/escaping, etc... those are taken care by the jdbc driver. > Q2: How on earth do I use the BLOB methods? In particular setBlob(int=20 > parameterIndex, InputStream inputStream) and/or createBlob() and=20 > setBlob(int parameterIndex, Blob x)? >=20 I never did anything with BLOBs so no experience from me here. > Thanks a lot > Brad >=20 =2D-=20 Achilleas Mantzios From mail_4brad@yahoo.co.uk Tue Apr 7 14:09:49 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C7DB0632E69 for ; Tue, 7 Apr 2009 11:09:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 38524-10 for ; Tue, 7 Apr 2009 11:09:37 -0300 (ADT) X-Greylist: delayed 00:06:40.283651 by SQLgrey-1.7.6 Received: from smtp104.mail.mud.yahoo.com (smtp104.mail.mud.yahoo.com [209.191.85.214]) by mail.postgresql.org (Postfix) with SMTP id 9B92D63280E for ; Tue, 7 Apr 2009 11:09:43 -0300 (ADT) Received: (qmail 41386 invoked from network); 7 Apr 2009 14:03:01 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=qU2QRZ04no8/BNlvbi51cnxt5ejEo+MoT+LONSCyH0yVWqxbEnyLzTI1d+J6cree120DQv6zp9avdWfpZ+7Td5Pdto8/l1tn/NCy+HyqDE3tIEwiFVSINbiJV7ftfruUE9RHdTuAEiovLG9YqF0QHqa4nwNTFHY+6Tmopl1whko= ; Received: from unknown (HELO ?192.168.1.2?) (mail_4brad@121.73.20.162 with plain) by smtp104.mail.mud.yahoo.com with SMTP; 7 Apr 2009 14:03:00 -0000 X-Yahoo-Newman-Property: ymail-3 Message-ID: <49DB5D63.5040103@yahoo.co.uk> Date: Wed, 08 Apr 2009 02:04:19 +1200 From: Brad Milne User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: Achilleas Mantzios Subject: Re: BLOB help - yes I've read around! References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> In-Reply-To: <200904071657.08065.achill@matrix.gatewaynet.com> Content-Type: multipart/alternative; boundary="------------070902030007000606070405" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/15 X-Sequence-Number: 19462 This is a multi-part message in MIME format. --------------070902030007000606070405 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Thanks Achilleas So how do you save the bytea data? I get: Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, InputStream) is not yet implemented Achilleas Mantzios wrote: > Στις Tuesday 07 April 2009 16:31:11 ο/η Brad Milne έγραψε: > >> Hi all >> >> I'm a Java dev, new to postgres. I've just migrated an app during >> development from Derby to Postgres (due to better indexing features), >> but am very confused by the failing BLOB implementations. >> >> PostgreSQL: 8.3.7 >> PostgreSQL-JDBC: 8.3-604 >> JDK: 6 >> >> A lot of what I've seen in searches and even in the google groups page, >> seems to be related to older jdbc drivers, where BLOBs were supported, >> both for OID and bytea. I'm currently getting 'unimplemented' exceptions >> doing anything with BLOBs. >> >> My application saves sound files as byte arrays to the database. >> >> Q1: Given that it's sound and not text, would it be safe to use bytea >> given that certain characters need to be escaped? >> > > I have been storing binary data in bytea for ages with postgresql, > with no major problems. > Performance might be an issue. > It is a good practice to store along with the bytea value, > its mime type as well. > So in your binary library you could have mp3s,oggs,mpegs, ms docs, jpegs, pdfs, > and your servlet would know exactly the content type to serve to the client. > > Also to answer your question about safeness/escaping, etc... > those are taken care by the jdbc driver. > > >> Q2: How on earth do I use the BLOB methods? In particular setBlob(int >> parameterIndex, InputStream inputStream) and/or createBlob() and >> setBlob(int parameterIndex, Blob x)? >> >> > > I never did anything with BLOBs so no experience from me here. > > >> Thanks a lot >> Brad >> >> > > > > --------------070902030007000606070405 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Achilleas

So how do you save the bytea data? I get:
Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, InputStream) is not yet implemented



Achilleas Mantzios wrote:
Στις Tuesday 07 April 2009 16:31:11 ο/η Brad Milne έγραψε:
  
Hi all

I'm a Java dev, new to postgres. I've just migrated an app during 
development from Derby to Postgres (due to better indexing features), 
but am very confused by the failing BLOB implementations.

PostgreSQL: 8.3.7
PostgreSQL-JDBC: 8.3-604
JDK: 6

A lot of what I've seen in searches and even in the google groups page, 
seems to be related to older jdbc drivers, where BLOBs were supported, 
both for OID and bytea. I'm currently getting 'unimplemented' exceptions 
doing anything with BLOBs.

My application saves sound files as byte arrays to the database.

Q1: Given that it's sound and not text, would it be safe to use bytea 
given that certain characters need to be escaped?
    

I have been storing binary data in bytea for ages with postgresql,
with no major problems.
Performance might be an issue.
It is a good practice to store along with the bytea value,
its mime type as well.
So in your binary library you could have mp3s,oggs,mpegs, ms docs, jpegs, pdfs,
and your servlet would know exactly the content type to serve to the client.

Also to answer your question about safeness/escaping, etc...
those are taken care by the jdbc driver.

  
Q2: How on earth do I use the BLOB methods? In particular setBlob(int 
parameterIndex, InputStream inputStream) and/or createBlob() and 
setBlob(int parameterIndex, Blob x)?

    

I never did anything with BLOBs so no experience from me here.

  
Thanks a lot
Brad

    



  

--------------070902030007000606070405-- From achill@matrix.gatewaynet.com Tue Apr 7 14:21:35 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4D110632E69 for ; Tue, 7 Apr 2009 11:21:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 41545-05 for ; Tue, 7 Apr 2009 11:21:24 -0300 (ADT) X-Greylist: delayed 00:24:18.310988 by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id AF72463199C for ; Tue, 7 Apr 2009 11:21:31 -0300 (ADT) Received: from smadev.internal.net (localhost [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id n37ELTI5062562; Tue, 7 Apr 2009 17:21:29 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id n37ELSWT062561; Tue, 7 Apr 2009 17:21:28 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-jdbc@postgresql.org Subject: Re: BLOB help - yes I've read around! Date: Tue, 7 Apr 2009 16:21:28 +0200 User-Agent: KMail/1.9.7 Cc: Brad Milne References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> In-Reply-To: <49DB5D63.5040103@yahoo.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200904071721.28357.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/17 X-Sequence-Number: 19464 =CE=A3=CF=84=CE=B9=CF=82 Tuesday 07 April 2009 17:04:19 =CE=BF/=CE=B7 Brad = Milne =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > Thanks Achilleas >=20 > So how do you save the bytea data? I get: > Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int,=20 > InputStream) is not yet implemented >=20 I never worked with JDK 1.6 and JDBC4,=20 from http://jdbc.postgresql.org/download.html we see: "Support for JDBC4 methods is limited. The driver builds, but the majority = of new methods are stubbed out." i dont know if that is relevant, i just saw the "jdbc4" part in your org.po= stgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream Having said that, i usually call setBytes. >=20 >=20 > Achilleas Mantzios wrote: > > =CE=A3=CF=84=CE=B9=CF=82 Tuesday 07 April 2009 16:31:11 =CE=BF/=CE=B7 B= rad Milne =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > > =20 > >> Hi all > >> > >> I'm a Java dev, new to postgres. I've just migrated an app during=20 > >> development from Derby to Postgres (due to better indexing features),= =20 > >> but am very confused by the failing BLOB implementations. > >> > >> PostgreSQL: 8.3.7 > >> PostgreSQL-JDBC: 8.3-604 > >> JDK: 6 > >> > >> A lot of what I've seen in searches and even in the google groups page= ,=20 > >> seems to be related to older jdbc drivers, where BLOBs were supported,= =20 > >> both for OID and bytea. I'm currently getting 'unimplemented' exceptio= ns=20 > >> doing anything with BLOBs. > >> > >> My application saves sound files as byte arrays to the database. > >> > >> Q1: Given that it's sound and not text, would it be safe to use bytea= =20 > >> given that certain characters need to be escaped? > >> =20 > > > > I have been storing binary data in bytea for ages with postgresql, > > with no major problems. > > Performance might be an issue. > > It is a good practice to store along with the bytea value, > > its mime type as well. > > So in your binary library you could have mp3s,oggs,mpegs, ms docs, jpeg= s, pdfs, > > and your servlet would know exactly the content type to serve to the cl= ient. > > > > Also to answer your question about safeness/escaping, etc... > > those are taken care by the jdbc driver. > > > > =20 > >> Q2: How on earth do I use the BLOB methods? In particular setBlob(int= =20 > >> parameterIndex, InputStream inputStream) and/or createBlob() and=20 > >> setBlob(int parameterIndex, Blob x)? > >> > >> =20 > > > > I never did anything with BLOBs so no experience from me here. > > > > =20 > >> Thanks a lot > >> Brad > >> > >> =20 > > > > > > > > =20 >=20 >=20 =2D-=20 Achilleas Mantzios From achill@matrix.gatewaynet.com Tue Apr 7 14:29:50 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4CE176336AD for ; Tue, 7 Apr 2009 11:29:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 43554-06 for ; Tue, 7 Apr 2009 11:29:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id 7EC6C63351E for ; Tue, 7 Apr 2009 11:29:48 -0300 (ADT) Received: from smadev.internal.net (localhost [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id n37ETkmE062666; Tue, 7 Apr 2009 17:29:46 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id n37ETjlo062665; Tue, 7 Apr 2009 17:29:45 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-jdbc@postgresql.org Subject: Re: BLOB help - yes I've read around! Date: Tue, 7 Apr 2009 16:29:44 +0200 User-Agent: KMail/1.9.7 Cc: Brad Milne References: <49DB559F.3030805@yahoo.co.uk> <49DB5D63.5040103@yahoo.co.uk> <200904071721.28357.achill@matrix.gatewaynet.com> In-Reply-To: <200904071721.28357.achill@matrix.gatewaynet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200904071729.45205.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/18 X-Sequence-Number: 19465 I forgot to ask you which jdbc version do you use. I presume (with Postgresql 8.3.x) you use postgresql-8.3-604.jdbc4.jar -- Achilleas Mantzios From spam_eater@gmx.net Tue Apr 7 14:39:27 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8EBA86336B3 for ; Tue, 7 Apr 2009 11:39:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 44118-01 for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id C6C526336AD for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.hub.org (Postfix) with ESMTP id 4D5B2125A819 for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LrCSN-0002j1-3b for pgsql-jdbc@postgresql.org; Tue, 07 Apr 2009 14:39:19 +0000 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 14:39:19 +0000 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 14:39:19 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: BLOB help - yes I've read around! Date: Tue, 07 Apr 2009 16:39:06 +0200 Lines: 19 Message-ID: References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 In-Reply-To: <49DB5D63.5040103@yahoo.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.599 tagged_above=0 required=5 tests=RCVD_NUMERIC_HELO=2.599 X-Spam-Level: ** X-Archive-Number: 200904/19 X-Sequence-Number: 19466 Brad Milne, 07.04.2009 16:04: > So how do you save the bytea data? I get: > Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, > InputStream) is not yet implemented > The following has been working for me since I think 8.1 (and the corresponding JDBC driver): Statement stmt = con.prepareStatement( "INSERT INTO blob_table (id, blob_col) VALUES (?,?)"); stmt.setInt(1, 42); File blobFile = new File("my_picture.jpg"); InputStream in = new FileInputStream(blobFile); stmt.setBinaryStream(2, r, (int)f.length()); stmt.executeUpdate(); con.commit(); Thomas From mail_4brad@yahoo.co.uk Tue Apr 7 21:33:06 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1F16D6330FF for ; Tue, 7 Apr 2009 18:33:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 35396-07 for ; Tue, 7 Apr 2009 18:32:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp108.mail.mud.yahoo.com (smtp108.mail.mud.yahoo.com [209.191.85.218]) by mail.postgresql.org (Postfix) with SMTP id 19D506325FD for ; Tue, 7 Apr 2009 18:33:03 -0300 (ADT) Received: (qmail 45365 invoked from network); 7 Apr 2009 21:33:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=E1BuD6g9xpixx4crl4kXV8QqjwcuS51yxljCdbNmWZ0kVuRahQ1KBPWumWrU9J9vglrhuZVAJuPlgyQffKx2z/tvMvtj+Tcw59TkJMdjgQwwY9pMnGDx2jU4M1RcDwT0jbRXm5PLcCJ5gTrSOPPHinvLpbG48g4r0DjAGuUu0rE= ; Received: from unknown (HELO ?192.168.1.2?) (mail_4brad@121.73.20.162 with plain) by smtp108.mail.mud.yahoo.com with SMTP; 7 Apr 2009 21:33:01 -0000 X-YMail-OSG: skus0ngVM1mbMUlIA8eSKasJU0itrjclfmoEBZHOw4mmLUFupmpU4U.3gIuB4EsjAR6cLAE4Cw7M_qHJnhigvPLGDG5mH10FMBZU5yHZC67aNFgc.h.HwOMX85fl4y_YAuH8YtJjRdT2IOHaHlLVf8vsSyA9PSf3pUeBPAOwf_swjg79nb1TIB5WkUsl9d0VQKNtOb0rbJlwePXjjiAWJteVUUdt6tJMl1mo.EWbkGm5mILrnypkO1aL4OPBgmWVlV1WTAkswUUcdJFj X-Yahoo-Newman-Property: ymail-3 Message-ID: <49DBC6DC.5030609@yahoo.co.uk> Date: Wed, 08 Apr 2009 09:34:20 +1200 From: Brad Milne User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: Thomas Kellerer , Achilleas Mantzios Subject: Re: BLOB help - yes I've read around! References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=0.001 X-Spam-Level: X-Archive-Number: 200904/25 X-Sequence-Number: 19472 Thanks to you both This works for me Thomas. For completeness, here is the setter again with a couple of fixes: stmt.setBinaryStream(2,in,in.available()); or optionally (if it is a file): stmt.setBinaryStream(2,in,blobFile.length()); Thomas Kellerer wrote: > Brad Milne, 07.04.2009 16:04: >> So how do you save the bytea data? I get: >> Method >> org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, >> InputStream) is not yet implemented >> > > The following has been working for me since I think 8.1 (and the > corresponding JDBC driver): > > Statement stmt = con.prepareStatement( > "INSERT INTO blob_table (id, blob_col) VALUES (?,?)"); > stmt.setInt(1, 42); > > File blobFile = new File("my_picture.jpg"); > InputStream in = new FileInputStream(blobFile); > stmt.setBinaryStream(2, r, (int)f.length()); > stmt.executeUpdate(); > con.commit(); > > Thomas > > From spam_eater@gmx.net Tue Apr 7 21:42:02 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8D9BB6325FD for ; Tue, 7 Apr 2009 18:42:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86263-05 for ; Tue, 7 Apr 2009 18:42:01 -0300 (ADT) X-Greylist: delayed 07:02:36.752337 by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mail.postgresql.org (Postfix) with ESMTP id 1A6B96337EE for ; Tue, 7 Apr 2009 18:42:00 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LrJ3I-0004Tc-36 for pgsql-jdbc@postgresql.org; Tue, 07 Apr 2009 21:41:52 +0000 Received: from ppp-88-217-14-88.dynamic.mnet-online.de ([88.217.14.88]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 21:41:52 +0000 Received: from spam_eater by ppp-88-217-14-88.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 21:41:52 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: BLOB help - yes I've read around! Date: Tue, 07 Apr 2009 23:41:53 +0200 Lines: 16 Message-ID: References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> <49DBC6DC.5030609@yahoo.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ppp-88-217-14-88.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 In-Reply-To: <49DBC6DC.5030609@yahoo.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200904/26 X-Sequence-Number: 19473 Brad Milne wrote on 07.04.2009 23:34: > For completeness, here is the setter again > with a couple of fixes: > > stmt.setBinaryStream(2,in,in.available()); Do not use availabe() This will *not* give you the number of bytes that are "available" in the stream. Read the Javadocs carefully: it will give you the number of bytes that can be /read without blocking/ Most of the time this will not be the length of the stream. Thomas From mail_4brad@yahoo.co.uk Tue Apr 7 21:54:01 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 741BD6330FF for ; Tue, 7 Apr 2009 18:54:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 38955-10 for ; Tue, 7 Apr 2009 18:53:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp107.mail.mud.yahoo.com (smtp107.mail.mud.yahoo.com [209.191.85.217]) by mail.postgresql.org (Postfix) with SMTP id BE34E634268 for ; Tue, 7 Apr 2009 18:53:57 -0300 (ADT) Received: (qmail 93451 invoked from network); 7 Apr 2009 21:53:56 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=UxtMUNqCdCp5qgV/MQfxfnqEImSaMa3F46wQ1izq2cfhVO23MANk9ejzQQ8TccDiV99S18bLNwjArpLoE4NvUv6UQj7TGF87JwGYSMtnIMcrdsEsmHSVh7MzZst8Al36AeeqpadVtgTY4dVxooLqHEVLH/+eizj61Dh06b8iEDE= ; Received: from unknown (HELO ?192.168.1.2?) (mail_4brad@121.73.20.162 with plain) by smtp107.mail.mud.yahoo.com with SMTP; 7 Apr 2009 21:53:56 -0000 X-YMail-OSG: LX1hMhwVM1lbNziwztDVGh_7GzsMgJ7.F3ii6Ux54p2CFGSZtXUmertuCXXwMVdIPbUb6QHc5PGq_.l8ZvAdB854TnNdgrmFtIvL5gNdEBPMdIFibhTZAdJnWyAWiNxMa7pXevvxnYfeEj35Com5ZRazVpJHoTlGL6TBt78edmTo1XanLzcINdhqzhmvF4hTFGwk1hy2zuGdVUcVMaDZ9YK0XUnyDzEd4iISbB_taptcKHU3C8pSFCBrvcMHJzsGFrw_sws_uueYrtKCfXcDRfbvBrznQKUOChZ_Ed6e.lfUCJz5nbyM X-Yahoo-Newman-Property: ymail-3 Message-ID: <49DBCBC2.6080402@yahoo.co.uk> Date: Wed, 08 Apr 2009 09:55:14 +1200 From: Brad Milne User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: Thomas Kellerer Subject: Re: BLOB help - yes I've read around! References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> <49DBC6DC.5030609@yahoo.co.uk> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=AWL=0.000 X-Spam-Level: X-Archive-Number: 200904/27 X-Sequence-Number: 19474 Thomas Kellerer wrote: > Brad Milne wrote on 07.04.2009 23:34: >> For completeness, here is the setter again with a couple of fixes: >> >> stmt.setBinaryStream(2,in,in.available()); > > Do not use availabe() > > This will *not* give you the number of bytes that are "available" in > the stream. > > Read the Javadocs carefully: it will give you the number of bytes that > can be /read without blocking/ > > Most of the time this will not be the length of the stream. > Good point Thomas, I hear you. I shouldn't have written that hear as others could follow that. In my implementation it is ok as the stream is complete prior to persisting it. I have an AudioInputStream object, but it is always complete. If you think I should be therefore using a different method/db object then I'd be pleased to hear. Thanks Brad From spam_eater@gmx.net Wed Apr 8 06:39:02 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 46205632BB6 for ; Wed, 8 Apr 2009 03:39:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48307-02 for ; Wed, 8 Apr 2009 03:39:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mail.postgresql.org (Postfix) with ESMTP id E5128632348 for ; Wed, 8 Apr 2009 03:39:00 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LrRQz-00076X-Tj for pgsql-jdbc@postgresql.org; Wed, 08 Apr 2009 06:38:53 +0000 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Apr 2009 06:38:53 +0000 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Apr 2009 06:38:53 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: BLOB help - yes I've read around! Date: Wed, 08 Apr 2009 08:38:46 +0200 Lines: 22 Message-ID: References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> <49DBC6DC.5030609@yahoo.co.uk> <49DBCBC2.6080402@yahoo.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 In-Reply-To: <49DBCBC2.6080402@yahoo.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.599 tagged_above=0 required=5 tests=RCVD_IN_DNSWL_LOW=-1, RCVD_NUMERIC_HELO=2.599 X-Spam-Level: * X-Archive-Number: 200904/29 X-Sequence-Number: 19476 Brad Milne, 07.04.2009 23:55: >> Do not use availabe() >> >> This will *not* give you the number of bytes that are "available" in >> the stream. >> >> Read the Javadocs carefully: it will give you the number of bytes that >> can be /read without blocking/ >> >> Most of the time this will not be the length of the stream. >> > Good point Thomas, I hear you. I shouldn't have written that hear as > others could follow that. In my implementation it is ok as the stream is > complete prior to persisting it. I have an AudioInputStream object, but > it is always complete. If you think I should be therefore using a > different method/db object then I'd be pleased to hear. I have never used AudioInputStream. If that one reports the real size when calling available() then it would be the first InputStream that I have seen that does that ;) If you do use available() you should verify that the size of your BLOB (bytea) in the database is really what you expected. You have to test with sizes that exceed any potential buffer that takes place in the input stream, and I would inspect the source code for available(). Thomas