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