Re: JDBC

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: JDBC
Дата
Msg-id CAKFQuwY_7EdueER=eLfE9HWmw9hLi+bDM3SqCf2NLR5Dugk2Tw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: JDBC  (Chuck Davis <cjgunzel@gmail.com>)
Ответы Re: JDBC  (Chuck Davis <cjgunzel@gmail.com>)
Список pgsql-jdbc
On Sunday, June 10, 2018, Chuck Davis <cjgunzel@gmail.com> wrote:

        try {
            result = stat.execute("select exists (select 1 from
information_schema.tables where table_name = 'entities')");
            System.out.println("the checkEntity returned a result of "
+ result);
        } catch (SQLException ex) {
            Logger.getLogger(ClientConstants.class.getName()).log(Level.SEVERE,
null, ex);
            result = false;
            return result;
        }

Your query is putting "false" into cell (0,0) of a ResultSet.  You are failing to even look at the resultset to see if it holds a true or false.

The query should never fail since you aren't using the table name directly but are checking for it as a value in another table that always exists. The inner query returns zero records when the table doesn't exist and the EXISTS construct converts that to false.

David J.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: JDBC
Следующее
От: Chuck Davis
Дата:
Сообщение: Re: JDBC