必威体育Betway必威体育官网
当前位置:首页 > IT技术

spring boot datasource hikari 配置说明

时间:2019-08-10 01:12:07来源:IT技术作者:seo实验室小编阅读:82次「手机版」
 

hikari

hikari cp参数解释在:

https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby

原文如下:

username

This property sets the default authentication username used when obtainingConnectionsfrom the underlying driver. Note that for datasources this works in a very deterMinistic fashion by callingDataSource.getConnection(*username*, password)on the underlying DataSource. However, for Driver-based configurations, every driver is different. In the case of Driver-based, HikariCP will use thisusernameproperty to set auserproperty in thePropertiespassed to the driver’sDriverManager.getConnection(jdbcUrl, props)call. If this is not what you need, skip this method entirely and calladdDataSourceProperty("username", ...), for example.Default: none

password

This property sets the default authentication password used when obtainingConnectionsfrom the underlying driver. Note that for DataSources this works in a very deterministic fashion by callingDataSource.getConnection(username, *password*)on the underlying DataSource. However, for Driver-based configurations, every driver is different. In the case of Driver-based, HikariCP will use thispasswordproperty to set apasswordproperty in thePropertiespassed to the driver’sDriverManager.getConnection(jdbcUrl, props)call. If this is not what you need, skip this method entirely and calladdDataSourceProperty("pass", ...), for example.Default: none

Frequently used

autoCommit

This property controls the default auto-commit behavior of connections returned from the pool. It is a boolean value.Default: true

connectionTimeout

This property controls the maximum number of milliseconds that a client (that’s you) will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a sqlException will be thrown. Lowest acceptable connection timeout is 250 ms.Default: 30000 (30 seconds)

idleTimeout

This property controls the maximum amount of time that a connection is allowed to sit idle in the pool.This setting only APPlies whenminimumIdleis defined to be less thanmaximumPoolSize.Idle connections willnotbe retired once the pool reachesminimumIdleconnections. Whether a connection is retired as idle or not is subject to a maximum variation of +30 seconds, and average variation of +15 seconds. A connection will never be retired as idlebeforethis timeout. A value of 0 means that idle connections are never removed from the pool. The minimum allowed value is 10000ms (10 seconds).Default: 600000 (10 minutes)

maxLifetime

This property controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when it is closed will it then be removed. On a connection-by-connection basis, minor negative attenuation is applied to avoid mass-extinction in the pool.We strongly recommend setting this value, and it should be several seconds shorter than any database or infrastructure imposed connection time limit.A value of 0 indicates no maximum lifetime (infinite lifetime), subject of course to theidleTimeoutsetting.Default: 1800000 (30 minutes)

connectionTestQuery

If your driver supports JDBC4 we strongly recommend not setting this property.This is for “legacy” drivers that do not support the JDBC4Connection.isvalid() API. This is the query that will be executed just before a connection is given to you from the pool to validate that the connection to the database is still alive.Again, try running the pool without this property, HikariCP will log an ERROR if your driver is not JDBC4 compliant to let you know.Default: none

minimumIdle

This property controls the minimum number ofidle connectionsthat HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less thanmaximumPoolSize, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and responsiveness to spike demands, we recommendnotsetting this value and instead allowing HikariCP to act as afixed sizeconnection pool.Default: same as maximumPoolSize

maximumPoolSize

This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. A reasonable value for this is best determined by your execution environment. When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up toconnectionTimeoutmilliseconds before timing out. Please readabout pool sizing.Default: 10

metricRegistry

This property is only available via programmatic configuration or IoC container. This property allows you to specify an instance of aCodahale/DropwizardMetricRegistryto be used by the pool to record various metrics. See theMetricswiki page for details.Default: none

healthCheckRegistry

This property is only available via programmatic configuration or IoC container. This property allows you to specify an instance of aCodahale/DropwizardHealthCheckRegistryto be used by the pool to report current health information. See theHealth Checkswiki page for details.Default: none

poolName

This property represents a user-defined name for the connection pool and appears mainly in logging and JMX management consoles to identify pools and pool configurations.Default: auto-generated

Infrequently used

initializationFailTimeout

This property controls whether the pool will “fail fast” if the pool cannot be seeded with an initial connection successfully. Any positive number is taken to be the number of milliseconds to attempt to acquire an initial connection; the application thread will be blocked during this period. If a connection cannot be acquired before this timeout occurs, an exception will be thrown. This timeout is appliedaftertheconnectionTimeoutperiod. If the value is zero (0), HikariCP will attempt to obtain and validate a connection. If a connection is obtained, but fails validation, an exception will be thrown and the pool not started. However, if a connection cannot be obtained, the pool will start, but later efforts to obtain a connection may fail. A value less than zero will bypass any initial connection attempt, and the pool will start immediately while trying to obtain connections in the background. Consequently, later efforts to obtain a connection may fail.Default: 1

isolateInternalQueries

This property determines whether HikariCP isolates internal pool queries, such as the connection alive test, in their own transaction. Since these are typically read-only queries, it is rarely necessary to encapsulate them in their own transaction. This property only applies ifautoCommitis disabled.Default: false

allowPoolSuspension

This property controls whether the pool can be suspended and resumed through JMX. This is useful for certain failover automation scenariOS. When the pool is suspended, calls togetConnection()willnottimeout and will be held until the pool is resumed.Default: false

readOnly

This property controls whetherConnectionsobtained from the pool are in read-only mode by default. Note some databases do not support the concept of read-only mode, while others provide query optimizations when theConnectionis set to read-only. Whether you need this property or not will depend largely on your application and database.Default: false

registerMbeans

This property controls whether or not JMX Management Beans (“MBeans”) are registered or not.Default: false

catalog

This property sets the defaultcatalogfor databases that support the concept of catalogs. If this property is not specified, the default catalog defined by the JDBC driver is used.Default: driver default

connectionInitSql

This property sets a SQL statement that will be executed after every new connection creation before adding it to the pool. If this SQL is not valid or throws an exception, it will be treated as a connection failure and the standard retry logic will be followed.Default: none

driverClassName

HikariCP will attempt to resolve a driver through the DriverManager based solely on thejdbcUrl, but for some older drivers thedriverClassNamemust also be specified. Omit this property unless you get an obvious error message indicating that the driver was not found.Default: none

transactionisolation

This property controls the default transaction isolation level of connections returned from the pool. If this property is not specified, the default transaction isolation level defined by the JDBC driver is used. Only use this property if you have specific isolation requirements that are common for all queries. The value of this property is the constant name from theConnectionclass such asTRANSACTION_READ_COMMITTED,TRANSACTION_REPEATABLE_READ, etc.Default: driver default

validationTimeout

This property controls the maximum amount of time that a connection will be tested for aliveness. This value must be less than theconnectionTimeout. Lowest acceptable validation timeout is 250 ms.Default: 5000

leakDetectionthreshold

This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak. A value of 0 means leak detection is disabled. Lowest acceptable value for enabling leak detection is 2000 (2 seconds).Default: 0

dataSource

This property is only available via programmatic configuration or IoC container. This property allows you to directly set the instance of theDataSourceto be wrapped by the pool, rather than having HikariCP construct it via reflection. This can be useful in some dependency injection frameworks. When this property is specified, thedataSourceClassNameproperty and all DataSource-specific properties will be ignored.Default: none

schema

This property sets the defaultschemafor databases that support the concept of schemas. If this property is not specified, the default schema defined by the JDBC driver is used.Default: driver default

threadFactory

This property is only available via programmatic configuration or IoC container. This property allows you to set the instance of thejava.util.concurrent.ThreadFactorythat will be used for creating all threads used by the pool. It is needed in some restricted execution environments where threads can only be created through aThreadFactoryprovided by the application container.Default: none

scheduledExecutor

This property is only available via programmatic configuration or IoC container. This property allows you to set the instance of thejava.util.concurrent.scheduledexecutorservicethat will be used for various internally scheduled tasks. If supplying HikariCP with ascheduledthreadpoolexecutorinstance, it is recommended thatsetRemoveOnCancelPolicy(true)is used.Default: none

相关阅读

ubuntu下配置bind9为局域网的DNS服务器

一、配置bind9服务器之前,先了解这些知识点:1、DNS解析过程详解:http://www.cnblogs.com/liyuanhong/articles/7353974.html2、常用

树莓派配置局域网打印服务器(HP1018)

树莓派装的是Ubuntu mate系统 准备工作 通过ssh登陆到树莓派 安装HPLIP(hp打印机驱动) sudo apt-get install hplip 安装CUPS(在

Spring AOP的实现原理(二)

**二、AOP的设计与实现 1、JVM的动态代理特性** 在Spring AOP实现中, 使用的核心技术时动态代理,而这种动态代理实

最新鲜最详细的Android SDK下载安装及配置教程

转载自:http://blog.csdn.net/dr_neo/article/details/49870587最近Neo突发神经,想要将学过的一些计算机视觉、机器学习中的算法都

一.linux开发之uboot移植(一)——初识uboot

参考博文: http://blog.51cto.com/9291927/1791237 一、uboot简介 U-Boot,全称 Universal Boot Loader,是遵循GPL条款的从FADSROM

分享到:

栏目导航

推荐阅读

热门阅读