Springboot database Connection pool Common configuration __ Database

Source: Internet
Author: User
Tags connection pooling

The configuration file is added as follows (I am using a multiple data source):

spring.datasource.primary.url=jdbc\:mysql\://localhost\:3306/test?useunicode\=true&characterencoding\= Utf-8
Spring.datasource.primary.username=test
spring.datasource.primary.password=123456
Spring.datasource.primary.driver-class-name=com.mysql.jdbc.driver
#验证连接的有效性
Spring.datasource.primary.test-while-idle=true
#获取连接时候验证, can affect performance
Spring.datasource.primary.test-on-borrow=false
#在连接归还到连接池时是否测试该连接
Spring.datasource.primary.test-on-return=false
Spring.datasource.primary.validation-query=select 1 from DUAL
#空闲连接回收的时间间隔, use with Test-while-idle, set for 5 minutes
spring.datasource.primary.time-between-eviction-runs-millis=300000
#连接池空闲连接的有效时间, set for 30 minutes
spring.datasource.primary.min-evictable-idle-time-millis=1800000
Spring.datasource.primary.initial-size=5
#指定连接池中最大的活跃连接数.
Spring.datasource.primary.max-active=50
#指定连接池等待连接返回的最大等待时间, millisecond unit.
spring.datasource.primary.max-wait=60000
#指定必须保持连接的最小值
Spring.datasource.primary.min-idle=5

spring.datasource.secondary.url=jdbc\:mysql\://localhost\:3306/test2?useunicode\=true&characterencoding\= Utf-8
Spring.datasource.secondary.username=test
spring.datasource.secondary.password=123456
Spring.datasource.secondary.driver-class-name=com.mysql.jdbc.driver
#验证连接的有效性
Spring.datasource.secondary.test-while-idle=true
#获取连接时候验证, can affect performance
Spring.datasource.secondary.test-on-borrow=false
#在连接归还到连接池时是否测试该连接
Spring.datasource.secondary.test-on-return=false
Spring.datasource.secondary.validation-query=select 1 from DUAL
#空闲连接回收的时间间隔, use with Test-while-idle, set for 5 minutes
spring.datasource.secondary.time-between-eviction-runs-millis=300000
#连接池空闲连接的有效时间, set for 30 minutes
spring.datasource.secondary.min-evictable-idle-time-millis=1800000
Spring.datasource.secondary.initial-size=5
#指定连接池中最大的活跃连接数.
Spring.datasource.secondary.max-active=50
#指定连接池等待连接返回的最大等待时间, millisecond unit.
spring.datasource.secondary.max-wait=60000
#指定必须保持连接的最小值
Spring.datasource.secondary.min-idle=5

DataSource

Spring.dao.exceptiontranslation.enabled whether to open Persistenceexceptiontranslationpostprocessor, default to True

Spring.datasource.abandon-when-percentage-full set timeout to be closed or escalated when the number of obsolete connections is accounted for

Spring.datasource.allow-pool-suspension allow connection pooling to be paused when using Hikari pool, default: False

Spring.datasource.alternate-username-allowed whether to allow alternate user names.

SPRING.DATASOURCE.AUTO-COMMIT Specifies whether updates is automatically submitted.

SPRING.DATASOURCE.CATALOG Specifies the default catalog.

Spring.datasource.commit-on-return set whether to commit all outstanding transactions when the connection is returned

SPRING.DATASOURCE.CONNECTION-INIT-SQL Specifies that the connection is created and then executed before being added to the connection pool.

SPRING.DATASOURCE.CONNECTION-INIT-SQLS when using DBCP connection pool, specify the SQL to execute when initializing

Spring.datasource.connection-properties. [key] Specifies the properties to configure when using the DBCP connection pool

SPRING.DATASOURCE.CONNECTION-TEST-QUERY specifies the SQL statement that verifies the legality of the connection execution

SPRING.DATASOURCE.CONNECTION-TIMEOUT specifies the time-out period for the connection, in milliseconds.

Spring.datasource.continue-on-error encountered an error while initializing the database, default false

Spring.datasource.data specified data (DML) script

SPRING.DATASOURCE.DATA-SOURCE-CLASS-NAME Specifies the fully qualified name of the data source.

Spring.datasource.data-source-jndi Specify the address of the Jndi

Spring.datasource.data-source-properties. [Key] Specifies the property to set when using the Hikari connection pool

Spring.datasource.db-properties use Tomcat connection pool to specify the properties to set

Whether the spring.datasource.default-auto-commit is automatically submitted.

SPRING.DATASOURCE.DEFAULT-CATALOG Specifies the default catalog for the connection.

Spring.datasource.default-read-only whether to set the default connection read-only.

SPRING.DATASOURCE.DEFAULT-TRANSACTION-ISOLATION Specifies the default isolation level for a connected transaction.

SPRING.DATASOURCE.DRIVER-CLASS-NAME specifies the class name of the driver, which is automatically detected by default from the JDBC URL.

Spring.datasource.fair-queue whether to use FIFO to return the connection.

Spring.datasource.health-check-properties. [Key] The properties passed when the heartbeat is checked using the Hikari connection pool

SPRING.DATASOURCE.IDLE-TIMEOUT Specifies how long the connection is not used, is set to idle, and the default is 10ms

Spring.datasource.ignore-exception-on-pre-load whether the exception is ignored when the connection pool is initialized.

Spring.datasource.init-sql the SQL that executes when the connection is created

SPRING.DATASOURCE.INITIAL-SIZE Specifies the number of connections initially established when the connection pool is started

Spring.datasource.initialization-fail-fast when creating a connection pool, you cannot create a specified minimum number of connections to throw an exception

SPRING.DATASOURCE.INITIALIZE Specifies whether to initialize the data source, initialize it with Data.sql, default: True

Spring.datasource.isolate-internal-queries Specify whether internal queries are to be quarantined, default to False

When Spring.datasource.jdbc-interceptors uses Tomcat connection pool, specify the JDBC Interceptor, semicolon-delimited

SPRING.DATASOURCE.JDBC-URL Specifies the JDBC URL.

spring.datasource.jmx-enabled if JMX is turned on, default is: false

SPRING.DATASOURCE.JNDI-NAME Specifies the name of the Jndi.

Spring.datasource.leak-detection-threshold how many milliseconds to detect a connection leak when using Hikari connection pool.

Spring.datasource.log-abandoned uses DBCP connection pool to track discarded statement or connections, by default: false

Spring.datasource.log-validation-errors whether to print checksum errors when using Tomcat connection pool.

SPRING.DATASOURCE.LOGIN-TIMEOUT specifies the time-out period for connecting to the database.

spring.datasource.max-active Specifies the maximum number of active connections in the connection pool.

Spring.datasource.max-age Specify the maximum age for connections in a connection pool

SPRING.DATASOURCE.MAX-IDLE Specifies the maximum number of idle connections for the connection pool.

SPRING.DATASOURCE.MAX-LIFETIME Specifies the maximum lifetime of connections in the connection pool, in milliseconds.

spring.datasource.max-open-prepared-statements Specifies the maximum number of open prepared statements.

SPRING.DATASOURCE.MAX-WAIT Specifies the maximum wait time, in milliseconds, that the connection pool waits for the connection to return.

SPRING.DATASOURCE.MAXIMUM-POOL-SIZE Specifies the maximum number of connections for the connection pool, including the and idle connections that are in use.

Spring.datasource.min-evictable-idle-time-millis Specifies how long an idle connection can be cleared after a minimum of idle time.

SPRING.DATASOURCE.MIN-IDLE Specifies the minimum value that must remain connected (for DBCP and Tomcat connection pools)

SPRING.DATASOURCE.MINIMUM-IDLE Specifies the minimum number of idle connections maintained by the connection, as specified when using HIKARICP.

SPRING.DATASOURCE.NAME Specifies the name of the data source.

SPRING.DATASOURCE.NUM-TESTS-PER-EVICTION-RUN Specifies the number of objects to run each idle object Evictor thread

SPRING.DATASOURCE.PASSWORD Specifies the database password.

Spring.datasource.platform Specifies the platform (schema-${platform}.sql) to use for the schema, by default: All

SPRING.DATASOURCE.POOL-NAME Specifies the connection pool name.

spring.datasource.pool-prepared-statements Specifies whether to pool statements.

Spring.datasource.propagate-interrupt-state whether the interrupt state is propagated if the thread is interrupted while waiting for a connection.

Spring.datasource.read-only whether to mark a data source read-only when using Hikari connection pool

Spring.datasource.register-mbeans Specifies whether the Hikari connection pool registers jmx Mbeans.

spring.datasource.remove-abandoned Specifies whether the connection is deleted immediately when the connection exceeds the obsolete timeout.

SPRING.DATASOURCE.REMOVE-ABANDONED-TIMEOUT specifies when the connection should be discarded.

Spring.datasource.rollback-on-return whether the pending transaction is rolled back when the connection is returned.

SPRING.DATASOURCE.SCHEMA Specifies schema (DDL) scripts.

SPRING.DATASOURCE.SEPARATOR Specifies the statement delimiter for the initialization script, by default:;

spring.datasource.sql-script-encoding specifies the SQL scripts encoding.

SPRING.DATASOURCE.SUSPECT-TIMEOUT specifies the time-out period before the discarded connection is printed.

Spring.datasource.test-on-borrow whether to test the connection when borrowing from the connection pool.

Whether to test the connection when Spring.datasource.test-on-connect is created

Spring.datasource.test-on-return whether the connection is tested when the connection is returned to the connection pool.

Spring.datasource.test-while-idle whether to perform a connection test when the connection is idle.

Spring.datasource.time-between-eviction-runs-millis Specify the operation interval between idle connection checking, obsolete connection cleanup, and idle connection pool sizing

SPRING.DATASOURCE.TRANSACTION-ISOLATION Specifies the transaction isolation level, which is specified when using the Hikari connection pool

SPRING.DATASOURCE.URL Specifies the JDBC URL.

Spring.datasource.use-disposable-connection-facade whether the connection is packaged to prevent the connection from being used after it is closed.

Spring.datasource.use-equals use String.Equals () to replace = = when comparing method names.

Spring.datasource.use-lock whether to lock the connection operation

SPRING.DATASOURCE.USERNAME Specifies the database name.

SPRING.DATASOURCE.VALIDATION-INTERVAL Specifies how many MS performs a connection checksum.

SPRING.DATASOURCE.VALIDATION-QUERY specifies the SQL query statement that connects checksums when a connection is obtained.

SPRING.DATASOURCE.VALIDATION-QUERY-TIMEOUT specifies the time-out period for connection checksum queries.

Spring.datasource.validation-timeout sets the timeout for connection checksums, specified when using Hikari connection pool

Spring.datasource.validator-class-name the validator fully qualified name used to test the query.

SPRING.DATASOURCE.XA.DATA-SOURCE-CLASS-NAME Specifies the fully qualified name of the data source.

Spring.datasource.xa.properties specifies the properties to be passed to XA data source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.