pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedprepared statement using postgres array
6+ messages / 3 participants
[nested] [flat]
* prepared statement using postgres array
@ 2007-11-30 14:07 Christian Kindler <christian.kindler@gmx.net>
2007-11-30 16:40 ` Re: prepared statement using postgres array Dave Cramer <pg@fastcrypt.com>
2007-12-01 12:55 ` Re: prepared statement using postgres array Kris Jurka <books@ejurka.com>
0 siblings, 2 replies; 6+ messages in thread
From: Christian Kindler @ 2007-11-30 14:07 UTC (permalink / raw)
To: pgsql-jdbc
Hello
I have read a lot but did not find any solution for inserting a array of floats into pg database via jdbc and prepared statements.
Can anyone please help me out?
Thanks
Christian
--
cu
Chris
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: prepared statement using postgres array
2007-11-30 14:07 prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
@ 2007-11-30 16:40 ` Dave Cramer <pg@fastcrypt.com>
2007-11-30 17:43 ` Re: prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
1 sibling, 1 reply; 6+ messages in thread
From: Dave Cramer @ 2007-11-30 16:40 UTC (permalink / raw)
To: Christian Kindler <christian.kindler@gmx.net>; +Cc: pgsql-jdbc
Christian,
Look through our test code, essentially you have to implement the
java.sql.Array interface on an object which contains an array of
floats and pass that in.
Dave
On 30-Nov-07, at 9:07 AM, Christian Kindler wrote:
> Hello
>
> I have read a lot but did not find any solution for inserting a
> array of floats into pg database via jdbc and prepared statements.
>
> Can anyone please help me out?
>
> Thanks
> Christian
> --
> cu
> Chris
>
> Psssst! Schon vom neuen GMX MultiMessenger gehört?
> Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: prepared statement using postgres array
2007-11-30 14:07 prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
2007-11-30 16:40 ` Re: prepared statement using postgres array Dave Cramer <pg@fastcrypt.com>
@ 2007-11-30 17:43 ` Christian Kindler <christian.kindler@gmx.net>
2007-12-01 12:35 ` Re: prepared statement using postgres array Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 6+ messages in thread
From: Christian Kindler @ 2007-11-30 17:43 UTC (permalink / raw)
To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc
Hi Dave
> you have to implement the java.sql.Array
hmmm ... i have tried to find a sample implementation of the interface, but no success.
I am sure this is a ugly solution but I figures out a workaround:
INSERT INTO Quote(fi_id, market_id, "date", "time",
"open", high, low, "close", vol, oi,
bid, bidvol, ask, askvol,
last,
sysstatus,
buyers, buyersvol, sellers, sellersvol,
additional)
VALUES(?, ?, ?, ?,
?, ?, ?, ?, ?, ?,
?, ?, ?, ?,
?,
?,
(select string_to_array(?, ',')::float[]),
(select string_to_array(?, ',')::float[]),
(select string_to_array(?, ',')::float[]),
(select string_to_array(?, ',')::float[]),
(select string_to_array(?, ',')::float[])
);
... as is said not pretty but it works for the moment ...
Thanks!
Christian
PS But it still will be cool if anybody could provide me a sample snipped implementing java.sql.Array
--
cu
Chris
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: prepared statement using postgres array
2007-11-30 14:07 prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
2007-11-30 16:40 ` Re: prepared statement using postgres array Dave Cramer <pg@fastcrypt.com>
2007-11-30 17:43 ` Re: prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
@ 2007-12-01 12:35 ` Dave Cramer <pg@fastcrypt.com>
0 siblings, 0 replies; 6+ messages in thread
From: Dave Cramer @ 2007-12-01 12:35 UTC (permalink / raw)
To: Christian Kindler <christian.kindler@gmx.net>; +Cc: pgsql-jdbc
Christian,
I'm doing this from memory so you may have to adjust.
you really only need to implement toString on the interface.
and the getBaseType.
the method has to output "{e0,e1,e2...}"
Where eN is the element of the array
Dave
On 30-Nov-07, at 12:43 PM, Christian Kindler wrote:
> Hi Dave
>
>> you have to implement the java.sql.Array
>
> hmmm ... i have tried to find a sample implementation of the
> interface, but no success.
>
> I am sure this is a ugly solution but I figures out a workaround:
>
> INSERT INTO Quote(fi_id, market_id, "date", "time",
> "open", high, low, "close", vol, oi,
> bid, bidvol, ask, askvol,
> last,
> sysstatus,
> buyers, buyersvol, sellers, sellersvol,
> additional)
> VALUES(?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?,
> ?,
> ?,
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[])
> );
>
> ... as is said not pretty but it works for the moment ...
>
> Thanks!
> Christian
>
> PS But it still will be cool if anybody could provide me a sample
> snipped implementing java.sql.Array
>
>
> --
> cu
> Chris
>
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: prepared statement using postgres array
2007-11-30 14:07 prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
@ 2007-12-01 12:55 ` Kris Jurka <books@ejurka.com>
1 sibling, 0 replies; 6+ messages in thread
From: Kris Jurka @ 2007-12-01 12:55 UTC (permalink / raw)
To: Christian Kindler <christian.kindler@gmx.net>; +Cc: pgsql-jdbc
On Fri, 30 Nov 2007, Christian Kindler wrote:
> I have read a lot but did not find any solution for inserting a array of
> floats into pg database via jdbc and prepared statements.
>
Just now I've implemented the JDBC4 method Connection.createArrayOf, so if
you're using JDK1.6 and don't mind using a development driver that's
probably the best way to go.
http://ejurka.com/pgsql/jars/arr/
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: prepared statement using postgres array
@ 2007-12-03 18:35 Christian Kindler <christian.kindler@gmx.net>
0 siblings, 0 replies; 6+ messages in thread
From: Christian Kindler @ 2007-12-03 18:35 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris,
thanks a lot I'll use the develop driver - it works great for me!!
> you're using JDK1.6 and don't mind using a development driver that's
> probably the best way to go.
>
> http://ejurka.com/pgsql/jars/arr
Christian
--
cu
Chris
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2007-12-03 18:35 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-30 14:07 prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
2007-11-30 16:40 ` Dave Cramer <pg@fastcrypt.com>
2007-11-30 17:43 ` Christian Kindler <christian.kindler@gmx.net>
2007-12-01 12:35 ` Dave Cramer <pg@fastcrypt.com>
2007-12-01 12:55 ` Kris Jurka <books@ejurka.com>
2007-12-03 18:35 Re: prepared statement using postgres array Christian Kindler <christian.kindler@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox