Difference between setting sample size in Statement vs ResultSet

What is the difference between setting the sample size in Statement vs ResultSet? The Oracle documentation says that if the sample size is specified in the Statement, then it is also used by the ResultSet if the sample size is specified before the result set is received. What is the difference if I set it to Statement or ResultSet? I am using an Oracle database. The following is the Oracle documentation about this:

Sample size

By default, when Oracle JDBC starts a query, it retrieves the result set of 10 rows at a time from the database cursor. This is the default Oracle row fetch size value. You can change the number of rows received during each trip by the database cursor by changing the value of the row sample size.

Standard JDBC also allows you to specify the number of rows received with each database feedback for a query, and this number is called the sample size. In Oracle JDBC, the value of the prefetch string is used as the default fetch size in the offer object. Setting the sample size overrides the row selection parameter and affects subsequent queries executed through this operator object.

Sample size is also used in the result set. When the Statement object launches the query, the sample size of the operator object is passed to the result set object created by the query. However, you can also set the sample size in the result set object to override the sample size of the statement that was passed to it.

+7
java oracle jdbc resultset
source share
2 answers

The only place where the sample size really matters is on the ResultSet . When a ResultSet is created, it gets its sample size from the Statement , which was used to create it, but can be changed later.

Consider the default Statement sample size that will be passed to all ResultSet created. If you do not want to use this default value, you can override it.

+4
source share

There is no difference. If you set the sample size in the instruction, then it applies to all ResultSet instances that come from this statement.

+2
source share

All Articles