pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
passing array(java) to postgre sql function
2+ messages / 2 participants
[nested] [flat]

* passing array(java) to postgre sql function
@ 2006-02-14 10:11  bond <kirank174@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: bond @ 2006-02-14 10:11 UTC (permalink / raw)
  To: pgsql-sql

Hi All,

in postgreSql, i have written a function which accepts a String array
and inserts the contents to DB.
when i tested that function by passing the values like:

SELECT TEST_ARRAY('{xxx,yyyy,pppp,wwwwww}');

where TEST_ARRAY is my function name.

the records get inserted correctly. But now the problem is how to pass
the values from java to this function?

I have implemented the java.sql.Array interface, and given the actual
implementation to getArray() method, like this:

public Object getArray(){
    ArrayList temp = new ArrayList();
    temp.add("MMMM");
    temp.add("NNNN");
    temp.add("TTTTT");
    temp.add("QQQQQ");
    return temp.toArray();
  }
After this i am passing   this.getArray() values to database.

but at this point of time i get the following Exception:
org.postgresql.util.PSQLException: Unsupported Types value: 2,003
	at
org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1630)
	at
org.postgresql.jdbc3.AbstractJdbc3Statement.setObject(AbstractJdbc3Statement.java:1436)
	at
org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1636)

Is this the problem with the driver wht i am usng?


Can anyonme please help me to overcome this??


Waiting for your response,




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: passing array(java) to postgre sql function
@ 2006-02-22 09:17  Markus Schaber <schabi@logix-tt.com>
  parent: bond <kirank174@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Markus Schaber @ 2006-02-22 09:17 UTC (permalink / raw)
  To: bond <kirank174@gmail.com>; +Cc: pgsql-sql

Hi, Bond,

bond wrote:

> public Object getArray(){
>     ArrayList temp = new ArrayList();
>     temp.add("MMMM");
>     temp.add("NNNN");
>     temp.add("TTTTT");
>     temp.add("QQQQQ");
>     return temp.toArray();
>   }
> After this i am passing   this.getArray() values to database.

As a first guess, have a look at java.sql.Array interface.

And maybe the people on the pgsql-jdbc@postgresql.org mailing list know
better. :-)

HTH,
Markus


-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-02-22 09:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-14 10:11 passing array(java) to postgre sql function bond <kirank174@gmail.com>
2006-02-22 09:17 ` Markus Schaber <schabi@logix-tt.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