Skip site navigation (1) Skip section navigation (2)

Passing parameters to functions from Java

From: Sean Elliott <Sean(dot)Elliott(at)which(dot)co(dot)uk>
To: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Passing parameters to functions from Java
Date: 2004-03-02 17:07:35
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Having trouble with dates and smallints so far.
I think you get around it using casts like this:

		CallableStatement cs = conn.prepareCall("{ ? = call
ifc_send_status_change( date(?), int2(?) )}");
		java.sql.Date date;
		date = new java.sql.Date(2002 - 1900, 02 - 1, 26);
		System.out.println("date is " + date);
		cs.registerOutParameter(1, Types.INTEGER);
		cs.setString(2, "2002-02-26");
//		cs.setShort(2, (short)1);
//		cs.setDate(2, date);
		cs.setShort(3, (short)2);
		// 2002-02-26, 1
		int rowCount = cs.getInt(1);
		System.out.println("row count is " + rowCount);

Is there any decent documentation on this? Can't find any by the obvious
routes - all examples are too trivial.


Sean Elliott

This communication contains information which is confidential and may also
be privileged. It is for the exclusive use of the intended recipient(s). If
you are not the intended recipient please note that any distribution,
copying or use of this communication or the information in it is strictly
prohibited. If you received this communication in error, please notify us by
e-mail or by telephone (020 7770 7000) and then delete the e-mail and any
copies of it.

pgsql-jdbc by date

Next:From: Nicholas VeeserDate: 2004-03-02 21:41:11
Subject: No Exception thrown when there is a constraint violation, and delete fails
Previous:From: Bhushan BhangaleDate: 2004-03-02 15:44:51
Subject: Re: calling function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group