Home > Archive > PostgreSQL SQL > February 2006 > passing array(java) to postgre sql function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author passing array(java) to postgre sql function
bond

2006-02-14, 7:23 am

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('& #123;xxx,yyyy,pppp,w
wwwww}');

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. AbstractJdbc2Stateme
nt. setObject(AbstractJd
bc2Statement.java:1630)
at
org.postgresql.jdbc3. AbstractJdbc3Stateme
nt. setObject(AbstractJd
bc3Statement.java:1436)
at
org.postgresql.jdbc2. AbstractJdbc2Stateme
nt. setObject(AbstractJd
bc2Statement.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,

Markus Schaber

2006-02-25, 9:48 am

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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com