Fetch size gives the JDBC driver a hint to the number of rows that should be fetched from the database when more rows are needed.
Fetch size is defined in QueryBuilder.java class (package com.lutris.dods.builder.generator.query). Two values are defined:
iDefaultFetchSize - default fetch size (static variable) - depeds on value from configuration file
iCurrentFetchSize - current fetch size (non-static variable) - value for current query
DefaultFetchSize is one of the parameters (optional) of the applications configuration file. This parameter (among some other parameters) is read by the constructor:
StandardDatabaseManager(Config config)
of
StandardDatabaseManager.java class.
This parameter can be accessed with method:
DODS.getDatabaseManager().getDatabaseManagerConfiguration().getFetchSize()
The default values for iDefaultFetchSize and iCurrentFetchSize are:
private static int iDefaultFetchSize = -1
private int iCurrentFetchSize = -1;
This value means that default and current fetch sizes are not defined.
The fetch size is used in QueryBuilder's method:
private void prepareStatement( DBConnection conn )
This method generates a JDBC PreparedStatement using the values passed for the where-clauses. If current fetch size is defined, that value is used. If not, the default fetch size is used. If this value is also not defined, the fetch size is not set for that JDBC PreparedStatement.
There are two methods in Query class that work with fetch size for current query. They are:
set_FetchSize (int iCurrentFetchSizeIn)
Sets the current fetch size (does not update configuration file), overrides default value.
get_FetchSize()
Reads the current value of fetch size. If new value is not set using set_FetchSize method, returns default value.