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
#获取连接时候验证, can affect performance
Spring.datasource.primary.validation-query=select 1 from DUAL
#空闲连接回收的时间间隔, use with Test-while-idle, set for 5 minutes
#连接池空闲连接的有效时间, set for 30 minutes
#指定连接池等待连接返回的最大等待时间, millisecond unit.

spring.datasource.secondary.url=jdbc\:mysql\://localhost\:3306/test2?useunicode\=true&characterencoding\= Utf-8
#获取连接时候验证, can affect performance
Spring.datasource.secondary.validation-query=select 1 from DUAL
#空闲连接回收的时间间隔, use with Test-while-idle, set for 5 minutes
#连接池空闲连接的有效时间, set for 30 minutes
#指定连接池等待连接返回的最大等待时间, millisecond unit.


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.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.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.