From: | Vance Maverick <vmaverick(at)pgp(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: UUID as primary key |
Date: | 2006-08-22 17:03:51 |
Message-ID: | 1156266231.24659.24.camel@vmaverick-linux2.pgp.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks, I've gotten this working nicely now (after some offline
exchanges with Harald).
In JDBC, inet values can be read a couple of ways -- the easiest is to
call ResultSet.getString(). And to write them, the easiest is to use
prepared statements of the form
INSERT INTO xxx VALUES (?::inet, ...)
SELECT * FROM xxx WHERE uuid = ?::inet
filling the parameters in with PreparedStatement.setString().
This is clearly a viable solution -- I'd be interested to hear from
others as well.
Vance
On Tue, 2006-08-22 at 17:14 +0200, Harald Armin Massa wrote:
> Vance,
>
> nice that it was of help.
>
> (When going from Java to the database, for example, it's
> easiest to compose the value directly into the SQL query
> rather than
> using a parameter.) This seems quite viable.
>
> Please allow me to recommend to you to NOT go this seemingly easy way.
> I went there myself (but did it in Python and PHP) some years ago,
> when I was young and needed the money.
>
> Those "put Data into your SQL Statements with String Substitution" is
> easy to get working in the first step; but gets very very hard to keep
> correct in the long run. Please google up topics like "SQL injection"
> and "escaping characters for SQL" - it is a source of endless
> frustration.
>
>
> Another tip to deal with GUIDs in applications:
> Because GUIDs are rather long when expressed in base16 (hexadecimal
> notion), I made a transformer to Base62, using numbers and all regular
> letters. That shortens the typical GUID from 32chars to 21chars.
>
> Harald
>
>
> --
> GHUM Harald Massa
> persuadere et programmare
> Harald Armin Massa
> Reinsburgstraße 202b
> 70197 Stuttgart
> 0173/9409607
> -
> Let's set so double the killer delete select all.
From | Date | Subject | |
---|---|---|---|
Next Message | Harpreet Dhaliwal | 2006-08-22 17:18:44 | Passing arguments to a trigger function |
Previous Message | Bryan White | 2006-08-22 16:26:53 | share library version problems |