Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9C6E86339F1 for ; Thu, 18 Feb 2010 07:48:42 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 81812-02 for ; Thu, 18 Feb 2010 11:48:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f190.google.com (mail-yx0-f190.google.com [209.85.210.190]) by mail.postgresql.org (Postfix) with ESMTP id EE0726325E3 for ; Thu, 18 Feb 2010 07:48:31 -0400 (AST) Received: by yxe28 with SMTP id 28so5857757yxe.29 for ; Thu, 18 Feb 2010 03:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=om8q7j3BQBrdHPhC6MLJ+0u5Pfz5s7FhXRGBp2CccpU=; b=R6MkltZQhLqF9WazOWrqjK0qHQTqKlo8/UAfN8gjbtPqiUMb5qG74k8Sz7Ct2zddzf KjsRd2xvvEcTY8E8Yz2TQFdayBOh3m3/jYPt1HIzcAgNotp712bY5N87vkQhHIBaiH8L nshilbDi7lFkrgWGI7nFGLRzh67Oa1Coe3eW0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=xRMak8XGldNStNMo3BZn94kmHl9J0ayHvKNn7ecB98w50BpjKq+5gGYhH2a+uSTcqd 71dpwqDIcK2M28cZhQ9M9tgZRw7bqEiKOhT+a1RgDOfzhkT5BWbYCtRtsiWho5XTh6fJ H2Y2BmdMNiIhw56B0IYJzrxA31s+T72HT3CMI= MIME-Version: 1.0 Received: by 10.101.213.2 with SMTP id p2mr9016330anq.229.1266493710674; Thu, 18 Feb 2010 03:48:30 -0800 (PST) In-Reply-To: References: <98bbb46a1002160313m25967352s8b59e480e778d5c4@mail.gmail.com> Date: Thu, 18 Feb 2010 06:48:30 -0500 Message-ID: <98bbb46a1002180348r7e3bb0e8m9aa906ff41b9e4ad@mail.gmail.com> Subject: Re: Correct way to send a composite type to Postgres From: Jason Tesser To: Kris Jurka Cc: pgsql-jdbc Content-Type: multipart/alternative; boundary=001636c9252bbc2d6b047fde8b69 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.462 tagged_above=-10 required=5 tests=AWL=0.277, BAYES_20=-0.74, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201002/31 X-Sequence-Number: 20318 --001636c9252bbc2d6b047fde8b69 Content-Type: text/plain; charset=ISO-8859-1 yea that is what i did. I was wondering though if there are gotchas here for escaping? Are here are Utilities in the driver I can use to make sure the data is escaped ok? any thoughts here. I mean basically i did public String getValue() { return "(" + person.getId() + "," + person.getFirstName() + "," + person.getLastName() + "," + person.getMiddleName() + ")"; } On Thu, Feb 18, 2010 at 12:17 AM, Kris Jurka wrote: > > > On Tue, 16 Feb 2010, Jason Tesser wrote: > > I have a composite type that is an IN parameter for a Stored Function. >> How >> do I construct the type in Java? >> >> I know in Postgres I can do row(....) I was hoping for something a little >> more Javaish instead to having to build that String. >> >> Can I extend PGObject to accomplish this? >> > > Currently there isn't a great way to do this with the PG JDBC driver. You > can encapsulate the ugliness with PGObject, but you can't avoid it. If you > have a type that extends PGObject all you need to do is override the > toString method to format the data as the server expects it. > > Kris Jurka --001636c9252bbc2d6b047fde8b69 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable yea that is what i did.=A0 I was wondering though if there are gotchas here= for escaping?=A0 Are here are Utilities in the driver I can use to make su= re the data is escaped ok?=A0 any thoughts here.=A0

I mean basicall= y i did

public String getValue() {
=A0=A0=A0 =A0=A0=A0 return "(" = + person.getId() + "," + person.getFirstName() + "," + = person.getLastName() + "," + person.getMiddleName() + ")&quo= t;;
}


On Thu, Feb 18, 2010 at 12:17 AM, Kris J= urka <books@ejurka= .com> wrote:


On Tue, 16 Feb 2010, Jason Tesser wrote:

I have a composite type that is an IN parameter for a Stored Function.=A0 H= ow
do I construct the type in Java?

I know in Postgres I can do row(....)=A0 I was hoping for something a littl= e
more Javaish instead to having to build that String.

Can I extend PGObject to accomplish this?

Currently there isn't a great way to do this with the PG JDBC driver. = =A0You can encapsulate the ugliness with PGObject, but you can't avoid = it. =A0If you have a type that extends PGObject all you need to do is overr= ide the toString method to format the data as the server expects it.

Kris Jurka

--001636c9252bbc2d6b047fde8b69--