@@ -111,22 +111,22 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
111111 private boolean ignoreWarnings = true ;
112112
113113 /**
114- * If this variable is set to a non-zero value, it will be used for setting the
114+ * If this variable is set to a non-negative value, it will be used for setting the
115115 * fetchSize property on statements used for query processing.
116116 */
117- private int fetchSize = 0 ;
117+ private int fetchSize = - 1 ;
118118
119119 /**
120- * If this variable is set to a non-zero value, it will be used for setting the
120+ * If this variable is set to a non-negative value, it will be used for setting the
121121 * maxRows property on statements used for query processing.
122122 */
123- private int maxRows = 0 ;
123+ private int maxRows = - 1 ;
124124
125125 /**
126- * If this variable is set to a non-zero value, it will be used for setting the
126+ * If this variable is set to a non-negative value, it will be used for setting the
127127 * queryTimeout property on statements used for query processing.
128128 */
129- private int queryTimeout = 0 ;
129+ private int queryTimeout = - 1 ;
130130
131131 /**
132132 * If this variable is set to true then all results checking will be bypassed for any
@@ -224,7 +224,8 @@ public boolean isIgnoreWarnings() {
224224 * large result sets: Setting this higher than the default value will increase
225225 * processing speed at the cost of memory consumption; setting this lower can
226226 * avoid transferring row data that will never be read by the application.
227- * <p>Default is 0, indicating to use the JDBC driver's default.
227+ * <p>Default is -1, indicating to use the JDBC driver's default
228+ * (i.e. to not pass a specific fetch size setting on the driver).
228229 * @see java.sql.Statement#setFetchSize
229230 */
230231 public void setFetchSize (int fetchSize ) {
@@ -244,7 +245,8 @@ public int getFetchSize() {
244245 * the entire result set in the database or in the JDBC driver if we're
245246 * never interested in the entire result in the first place (for example,
246247 * when performing searches that might return a large number of matches).
247- * <p>Default is 0, indicating to use the JDBC driver's default.
248+ * <p>Default is -1, indicating to use the JDBC driver's default
249+ * (i.e. to not pass a specific max rows setting on the driver).
248250 * @see java.sql.Statement#setMaxRows
249251 */
250252 public void setMaxRows (int maxRows ) {
@@ -260,7 +262,8 @@ public int getMaxRows() {
260262
261263 /**
262264 * Set the query timeout for statements that this JdbcTemplate executes.
263- * <p>Default is 0, indicating to use the JDBC driver's default.
265+ * <p>Default is -1, indicating to use the JDBC driver's default
266+ * (i.e. to not pass a specific query timeout setting on the driver).
264267 * <p>Note: Any timeout specified here will be overridden by the remaining
265268 * transaction timeout when executing within a transaction that has a
266269 * timeout specified at the transaction level.
@@ -1386,11 +1389,11 @@ protected Map<String, Object> createResultsMap() {
13861389 */
13871390 protected void applyStatementSettings (Statement stmt ) throws SQLException {
13881391 int fetchSize = getFetchSize ();
1389- if (fetchSize > 0 ) {
1392+ if (fetchSize >= 0 ) {
13901393 stmt .setFetchSize (fetchSize );
13911394 }
13921395 int maxRows = getMaxRows ();
1393- if (maxRows > 0 ) {
1396+ if (maxRows >= 0 ) {
13941397 stmt .setMaxRows (maxRows );
13951398 }
13961399 DataSourceUtils .applyTimeout (stmt , getDataSource (), getQueryTimeout ());
0 commit comments