0

We are trying to implement the PostgreSQL JDBC driver protocol by creating a service that acts as a PostgreSQL database. Our customers are expected to use standard PostgreSQL clients, so we have no control over that. We can only control the backend implementation.

What I'm trying to do now is to send the LIMIT and OFFSET values using the JDBC API, and NOT within the query.

Sending the FETCH value can be done using the setMaxRows method but I can't find a way to send the OFFSET value.

I tried setting parameters to a prepared statement but the client threw an exception because no parameters where found in the prepared query. Which is expected.

So is there a way to send a parameter\attribute along with a query so the backend can read this parameter ? The parameter need to be query-scoped, meaning that it should only exist during a single specific execution.

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81
  • The answer [seems to be no](https://stackoverflow.com/questions/2771439/jdbc-pagination); if you want offset you'd need to include that in the SQL query. – Tim Biegeleisen Jul 03 '17 at 10:07
  • I'm a bit confused. If "[your] customers are expected to use standard PostgreSQL clients" and they want to run a query with LIMIT and OFFSET then one would expect them to send a query with LIMIT and OFFSET. How else would a "standard PostgreSQL client" do it? – Gord Thompson Jul 03 '17 at 15:44
  • @GordThompson, Good question. The backend is also expected to handle connections from an application that we're working on. That's were I need to use this behavior. – Muhammad Gelbana Jul 04 '17 at 16:56

0 Answers0