Passing Array from Java to Postgres

From: lathasuresh(dot)s(at)gmail(dot)com
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Passing Array from Java to Postgres
Date: 2008-11-04 06:18:23
Message-ID: 18395d43-777b-4b47-b533-478b4c61b995@e38g2000prn.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,
I need to pass array from Java to postgres DB.Tried the following
code given in net,but it doesnt work,please help me to solve this.

Getting no exceptions but program execution skips when it reaches
the following code
cstmt.setArray(2, connection.createArrayOf("int4", intarr ));

I have also copied the following code for reference,

DBConnection dbconn=new DBConnection();
Connection connection=dbconn.getDBConnection();
CallableStatement cstmt = connection.prepareCall("{?=
call testit(?)}");
cstmt.registerOutParameter(1, Types.INTEGER);
try{
cstmt.setArray(2, connection.createArrayOf("int4",
intarr ));
}catch(Exception e) {
e.printStackTrace();
}
cstmt.execute();
result = cstmt.getInt(1);

Regards,
Latha S

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gorka Mauleon 2008-11-04 07:45:43 JNDI Datasource in tomcat
Previous Message Kris Jurka 2008-11-04 00:45:14 Re: How to pass array in prepared statement for stored procedure execution?