From: Adriaan Joubert <a.joubert@albourne.com>
To: Katsaros Kwn/nos <ntinos@aueb.gr>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Java app and SPI functions
Date: Thu, 30 Sep 2004 16:28:20 +0300
Message-ID: <415C09F4.2090506@albourne.com> (raw)
In-Reply-To: <1096546604.5994.4.camel@localhost.localdomain>
References: <1096546604.5994.4.camel@localhost.localdomain>
Hi Ntinos,
You don't need to use PL/Java - you can call the SPI functions
through standard SQL. I have C functions that return tuples and call
them with executeQuery(...).
The function in question is defined as
CREATE TYPE correlation_type AS
(
id INTEGER,
num_points INTEGER,
correlation FLOAT8
);
CREATE OR REPLACE FUNCTION
max_min_correlation(int,smallint,smallint,int,int)
RETURNS SETOF correlation_type
AS '$libdir/contrib/my_func.so','max_min_correlation'
LANGUAGE 'C' STABLE STRICT;
and then I call it with
ResultSet results = st
.executeQuery("SELECT * FROM
max_min_correlation("+var+")");
and work through the result set.
Good luck,
Adriaan
Katsaros Kwn/nos wrote:
>Hi everybody!
>
>I'm new to PostgreSQL with JDBC. What I want to do is to connect an
>already implemented Java application to my postgresql server.I want to
>be able to pass arguments from the java application to some function
>I've written in C (that uses SPI functions) and receive tuples to
>display in the Java GUI.
>
>Any hints on where to start from?
>
>Richard Huxton at the General list kindly pointed me to the PL/Java
>project. Is this where I should focus?
>
>Thanks in advance,
>Ntinos Katsaros
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
Attachments:a.joubert.vcf (text/x-vcard, 286B) download
begin:vcard
fn:Adriaan Joubert
n:Joubert;Adriaan
org:Albourne Partners (Cyprus) Ltd
adr:;;3 D. Vikella Street;Nicosia;;1061;Cyprus
email;internet:a.joubert@albourne.com
tel;work:+357 22 750652
tel;fax:+357 22 750654
x-mozilla-html:FALSE
url:http://www.albourne.com
version:2.1
end:vcard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: a.joubert@albourne.com, ntinos@aueb.gr
Subject: Re: Java app and SPI functions
In-Reply-To: <415C09F4.2090506@albourne.com>
References: <1096546604.5994.4.camel@localhost.localdomain> <415C09F4.2090506@albourne.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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