pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedRE : Postgres 8.0 + JDBC
3+ messages / 2 participants
[nested] [flat]
* RE : Postgres 8.0 + JDBC
@ 2004-10-06 07:20 Johann Robette <jrobette@onyme.com>
2004-10-06 16:47 ` Re: RE : Postgres 8.0 + JDBC Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 3+ messages in thread
From: Johann Robette @ 2004-10-06 07:20 UTC (permalink / raw)
To: 'Oliver Jowett' <oliver@opencloud.com>; +Cc: pgsql-jdbc
OK Thanks a lot for your answer.
But as I'm a newbie in this field, could you give me an example of how
to do that.
I've already checked the array typename and it is "_text".
You said :
"It seems possible to fix the driver to handle this case by making
setArray() derive a proper array type name i.e. ("_" +
Array.getBaseType()), and using that rather than 'text' as the parameter
type."
How to do that?
Thanks
JR
-----Message d'origine-----
De : Oliver Jowett [mailto:oliver@opencloud.com]
Envoyé : mardi 5 octobre 2004 22:11
À : Johann Robette
Cc : pgsql-jdbc@postgresql.org
Objet : Re: [JDBC] Postgres 8.0 + JDBC
Johann Robette wrote:
> java.sql.SQLException: ERROR: cannot cast type text to
> text[]
setArray has never worked particularly well; you're seeing another
manifestation here.
The underlying problem here is that:
- setArray() is claiming that the type it is setting is a VARCHAR
- the parameter is being passed as a typed parameter via the V3
protocol, with type = 'text'
- apparently you can't cast directly from text -> text[] (although you
can interpret an untyped literal as text[], which is why it worked
before).
It seems possible to fix the driver to handle this case by making
setArray() derive a proper array type name i.e. ("_" +
Array.getBaseType()), and using that rather than 'text' as the parameter
type.
I'll try to do this soon, but I'm a bit busy so it may be a few days.
A longer term fix is to properly implement array support in setArray()..
I've submitted patches in the past to do this but they've never made it
into the official driver.
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: RE : Postgres 8.0 + JDBC
2004-10-06 07:20 RE : Postgres 8.0 + JDBC Johann Robette <jrobette@onyme.com>
@ 2004-10-06 16:47 ` Kris Jurka <books@ejurka.com>
2004-10-14 21:18 ` Re: RE : Postgres 8.0 + JDBC Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 3+ messages in thread
From: Kris Jurka @ 2004-10-06 16:47 UTC (permalink / raw)
To: Johann Robette <jrobette@onyme.com>; +Cc: Oliver Jowett <oliver@opencloud.com>; pgsql-jdbc
On Wed, 6 Oct 2004, Johann Robette wrote:
> But as I'm a newbie in this field, could you give me an example of how
> to do that.
It's not something you can do in your code. It will require changes to
the driver itself. Oliver or I will do this at some point, but I couldn't
say when. If you're desperate to get a fix immediately I've attached a
patch implementing the inferior solution I suggested that made a simple
test work for me.
Kris Jurka
Attachments:
arr.type.patch (text/plain, 913B) download
Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v
retrieving revision 1.31
diff -c -r1.31 AbstractJdbc2Statement.java
*** org/postgresql/jdbc2/AbstractJdbc2Statement.java 21 Sep 2004 01:14:06 -0000 1.31
--- org/postgresql/jdbc2/AbstractJdbc2Statement.java 6 Oct 2004 16:45:32 -0000
***************
*** 2443,2449 ****
public void setArray(int i, java.sql.Array x) throws SQLException
{
checkClosed();
! setString(i, x.toString());
}
public void setBlob(int i, Blob x) throws SQLException
--- 2443,2449 ----
public void setArray(int i, java.sql.Array x) throws SQLException
{
checkClosed();
! setString(i, x.toString(), 0);
}
public void setBlob(int i, Blob x) throws SQLException
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: RE : Postgres 8.0 + JDBC
2004-10-06 07:20 RE : Postgres 8.0 + JDBC Johann Robette <jrobette@onyme.com>
2004-10-06 16:47 ` Re: RE : Postgres 8.0 + JDBC Kris Jurka <books@ejurka.com>
@ 2004-10-14 21:18 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 3+ messages in thread
From: Kris Jurka @ 2004-10-14 21:18 UTC (permalink / raw)
To: Johann Robette <jrobette@onyme.com>; +Cc: Oliver Jowett <oliver@opencloud.com>; pgsql-jdbc
On Wed, 6 Oct 2004, Kris Jurka wrote:
> On Wed, 6 Oct 2004, Johann Robette wrote:
>
> > But as I'm a newbie in this field, could you give me an example of how
> > to do that.
>
> It's not something you can do in your code. It will require changes to
> the driver itself. Oliver or I will do this at some point, but I couldn't
> say when. If you're desperate to get a fix immediately I've attached a
> patch implementing the inferior solution I suggested that made a simple
> test work for me.
>
Just wanted to follow up with you here in case you weren't carefully
following the mailing list. Oliver has provided a patch to make this
happen and it is now in the cvs repository.
It does require some changes to the PostgresArray class you sent. Notably
the datatype name needs to match up exactly with the pg data type (aliases
aren't allowed). So for example the create(long[] array) method currently
creates does this at the end:
return new PostgresArray(sb.toString(), Types.BIT, "bigint");
this now needs to use "int8" as the type name. The Types.BIT is also
bogus, but that currently isn't a problem.
Kris Jurka
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2004-10-14 21:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-06 07:20 RE : Postgres 8.0 + JDBC Johann Robette <jrobette@onyme.com>
2004-10-06 16:47 ` Kris Jurka <books@ejurka.com>
2004-10-14 21:18 ` Kris Jurka <books@ejurka.com>
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