Re: executeQuery - Mailing list pgsql-jdbc

From Fernando Nasser
Subject Re: executeQuery
Date
Msg-id 3F328283.4030608@redhat.com
Whole thread Raw
In response to executeQuery  ("Lufkin, Brad" <brad.lufkin@ngc.com>)
List pgsql-jdbc
Lufkin, Brad wrote:
> I'm executing an SQL query using the following code:
>
>     Connection connection =
> DriverManager.getConnection(url,user,password);
>     Statement statement = connection.createStatement();
>     ResultSet resultSet = statement.executeQuery("SELECT * FROM
> someTable");
>
> This works except that the third statement doesn't return until the query is
> complete. This contrasts with the behavior of other databases (such as
> Informix) where the query returns immediately, thus allowing the result set
> metadata to be analyzed before the result set is.
> Is there any way to force the executeQuery to return immediately?
> If not, is there some way to limit the results of the query to the first n
> rows, where n is some reasonable number?
>

You can either use LIMIT <n> in the SELECT statement itself or use the
setFetchSize() inside a transaction or with server-side prepared statements.



--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


pgsql-jdbc by date:

Previous
From: "Lufkin, Brad"
Date:
Subject: executeQuery
Next
From: Barry Lind
Date:
Subject: Re: SSL support in PG 7.4