strange java query behaviour

Поиск
Список
Период
Сортировка
От Szymon Guz
Тема strange java query behaviour
Дата
Msg-id CAFjNrYv4MrkbXi-usroCqNiaSyEAzvJ7GjtsEJW2RK7-R=8hiw@mail.gmail.com
обсуждение исходный текст
Ответы Re: strange java query behaviour
Список pgsql-general
Hi,
I've got a quite strange situation. Below is a simple test

    @Test
    public void test() throws SQLException {

        String query1 = "SELECT * FROM information_schema.schemata WHERE schema_name = ?";
        String query2 = "SELECT * FROM pg_catalog.pg_namespace where nspname = ?";

        check(query1, "1", "public");
        check(query2, "2", "public");

    }

    private void check(final String query, final String info, final String param) throws SQLException {
        PreparedStatement stmt = connection.prepareStatement(query);
        stmt.setString(1, param);
        ResultSet schemas = stmt.executeQuery();
        boolean exists = schemas.next();
        System.out.println(info + " : " + exists);
    }

The output is:

1 : false
2 : true

When I query the database using psql, both queries return sensible data (even when I prepare statements in postgres).

I'd like to use information_schema rather than using pg_catalog.

ENV:

Ubuntu 11.10
PostgreSQL 9.0.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
9.0-801.jdbc4


regards
Szymon


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

Предыдущее
От: Allan Kamau
Дата:
Сообщение: Help with copy (loading TSV file into table as text)
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Help with copy (loading TSV file into table as text)