001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.jdbc;
018
019import java.time.Duration;
020import java.time.temporal.ChronoUnit;
021
022import org.springframework.boot.context.properties.ConfigurationProperties;
023import org.springframework.boot.convert.DurationUnit;
024
025/**
026 * Configuration properties for JDBC.
027 *
028 * @author Kazuki Shimizu
029 * @author Stephane Nicoll
030 * @since 2.0.0
031 */
032@ConfigurationProperties(prefix = "spring.jdbc")
033public class JdbcProperties {
034
035        private final Template template = new Template();
036
037        public Template getTemplate() {
038                return this.template;
039        }
040
041        /**
042         * {@code JdbcTemplate} settings.
043         */
044        public static class Template {
045
046                /**
047                 * Number of rows that should be fetched from the database when more rows are
048                 * needed. Use -1 to use the JDBC driver's default configuration.
049                 */
050                private int fetchSize = -1;
051
052                /**
053                 * Maximum number of rows. Use -1 to use the JDBC driver's default configuration.
054                 */
055                private int maxRows = -1;
056
057                /**
058                 * Query timeout. Default is to use the JDBC driver's default configuration. If a
059                 * duration suffix is not specified, seconds will be used.
060                 */
061                @DurationUnit(ChronoUnit.SECONDS)
062                private Duration queryTimeout;
063
064                public int getFetchSize() {
065                        return this.fetchSize;
066                }
067
068                public void setFetchSize(int fetchSize) {
069                        this.fetchSize = fetchSize;
070                }
071
072                public int getMaxRows() {
073                        return this.maxRows;
074                }
075
076                public void setMaxRows(int maxRows) {
077                        this.maxRows = maxRows;
078                }
079
080                public Duration getQueryTimeout() {
081                        return this.queryTimeout;
082                }
083
084                public void setQueryTimeout(Duration queryTimeout) {
085                        this.queryTimeout = queryTimeout;
086                }
087
088        }
089
090}