Re: JDBC

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Chuck Davis <cjgunzel(at)gmail(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC
Date: 2018-06-10 23:26:52
Message-ID: CAKFQuwZJ8qLvKyX-JrFbysjHuWSDDFaMpbjXTGe-zhtOkDn2JA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Sunday, June 10, 2018, Chuck Davis <cjgunzel(at)gmail(dot)com> wrote:

> If I try to return a ResultSet the class will not compile with the
> message that boolean cannot be converted to a ResultSet. And this is
> in synch with the documentation that states the "exists" subquery will
> return a boolean -- not a ResultSet.
>
>
The PostgreSQL documentation doesn't talk in terms JDBC, the Oracle JDBC
API specification covers that.

https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html

JDBC uses ResultSet to return the results of queries.

> There are a number of sites that indicate the statement is the way to
> find out if a table exists. Are the sites for an older version of PG?
> I'm running on 10.
>

This really has nothing to do with PostgreSQL specifically, you are failing
to use the JDBC API correctly. In the short term you should probably just
use "executeQuery" instead of "execute" since you are in fact executing a
query that returns a ReaultSet (which is exactly what execute's true
boolean result is telling you).

David J.

In response to

  • Re: JDBC at 2018-06-10 23:09:39 from Chuck Davis

Responses

  • Re: JDBC at 2018-06-11 01:33:32 from Chuck Davis

Browse pgsql-jdbc by date

  From Date Subject
Next Message Chuck Davis 2018-06-11 01:33:32 Re: JDBC
Previous Message Chuck Davis 2018-06-10 23:21:34 Re: JDBC