Search code examples
javasqloracle-databasejdbcjndi

How to limit number of rows returned from Oracle at the JDBC data source level?


Is there a way to limit the rows returned at the Oracle datasource level in a Tomcat application?

It seems maxRows is only available if you set it on the datasource in the Java code. Putting maxRows="2" on the datasource doesn't apply.

Is there any other way limit the rows returned? Without a code change?


Solution

  • It isn't something that is available at the configuration level. You may want to double check that it does what you want it to do anyway: see the javadoc for setMaxRows. With Oracle it is still going to fetch every row back for the query and then just drop the ones outside the range. You would really need to use rownum to make it work well with Oracle and you can't do that either in the configuration.