Thread: Custom types and JDBC

Custom types and JDBC

From
mephysto
Date:
Hi,
I would use custom types in several stored functions and I would my sotred
function return these custom types.
I would launch stored functions and retrieve results by JDBC interface: is
it possible to map postgres custom types to java objects without resultset
use?

Thanks in advance.

Meph

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Custom-types-and-JDBC-tp4386655p4386655.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: Custom types and JDBC

From
Dave Cramer
Date:
Hi,

I'm not sure what you mean by without result set ? There is no real
way to get information back from the driver except using a result set.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca




On Wed, May 11, 2011 at 3:19 AM, mephysto <gennaria@email.it> wrote:
> Hi,
> I would use custom types in several stored functions and I would my sotred
> function return these custom types.
> I would launch stored functions and retrieve results by JDBC interface: is
> it possible to map postgres custom types to java objects without resultset
> use?
>
> Thanks in advance.
>
> Meph
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Custom-types-and-JDBC-tp4386655p4386655.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Re: Custom types and JDBC

From
mephysto
Date:
This is the point!

I would to know if an alternative of resultset exist to retrieve custom data
types from postgres by jdbc.

I explained me?

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Custom-types-and-JDBC-tp4387382p4387475.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: Custom types and JDBC

From
Adrian Klaver
Date:
On Wednesday, May 11, 2011 7:07:25 am mephysto wrote:
> This is the point!
>
> I would to know if an alternative of resultset exist to retrieve custom
> data types from postgres by jdbc.
>
> I explained me?

Not sure:) The information is in the server and the JDBC driver is external to
the server, so a query is involved. If I understand what you want is a query
that fetches the data types available in a server directly from the server
without parsing the results of arbitrary queries.  Not sure exactly what
information you are looking for, but the system catalog pg_type might be a
start.

>
> --

--
Adrian Klaver
adrian.klaver@gmail.com

Re: Custom types and JDBC

From
mephysto
Date:
Mmmmm no,
my goal is for example:  define a typeFoo (id as int, name as varchar) in
postgres, define an object in java objFoo (id as int, name string), define a
stored function in posgres return a typeFoo


create ora replace function getFoo() returns typeFoo as
$$
begin
......
end;
$$

I would to connect postgres by jdbc and call stored function getFoo. A this
poin I would set properties of objFoo (id and name) with id and name
retrieved from stored function.

Is resultset the only way to achieve this goal?

Thanks.

Meph

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Custom-types-and-JDBC-tp4387382p4387604.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: Custom types and JDBC

From
Adrian Klaver
Date:
On 05/11/2011 08:03 AM, mephysto wrote:
> Mmmmm no,
> my goal is for example:  define a typeFoo (id as int, name as varchar) in
> postgres, define an object in java objFoo (id as int, name string), define a
> stored function in posgres return a typeFoo
>
>
> create ora replace function getFoo() returns typeFoo as
> $$
> begin
> ......
> end;
> $$
>
> I would to connect postgres by jdbc and call stored function getFoo. A this
> poin I would set properties of objFoo (id and name) with id and name
> retrieved from stored function.
>
> Is resultset the only way to achieve this goal?

As far as I can tell, yes. If the values for id and name never changed
you could just hard code them as properties of objFoo. Assuming that the
function getFoo() changes the values, the only way you can know what the
new values are is query the database and get them from the result set.

>
> Thanks.
>
> Meph
>

--
Adrian Klaver
adrian.klaver@gmail.com

Re: Custom types and JDBC

From
Tom Lane
Date:
mephysto <gennaria@email.it> writes:
> my goal is for example:  define a typeFoo (id as int, name as varchar) in
> postgres, define an object in java objFoo (id as int, name string), define a
> stored function in posgres return a typeFoo

You'd probably be better off asking about this in the pgsql-jdbc list.

            regards, tom lane