1. 程式人生 > >quartz 2.2.1 jdbc 連線池引數配置

quartz 2.2.1 jdbc 連線池引數配置

線上資料庫出現mysql 8小時異常.需要增加如下配置:

org.quartz.dataSource.QRTZ_DS.idleConnectionValidationSeconds=60
org.quartz.dataSource.QRTZ_DS.validateOnCheckout=true
org.quartz.dataSource.QRTZ_DS.discardIdleConnectionsSeconds=0

增加後問題解決.

/** The JDBC database driver. */指定連線驅動
public static final String DB_DRIVER = "driver"
; /** The JDBC database URL. */ 連線字串 public static final String DB_URL = "URL"; /** The database user name. */ 使用者名稱 public static final String DB_USER = "user"; /** The database user password. */ 密碼 public static final String DB_PASSWORD = "password"; /** The maximum number of database connections to have in the pool. Default is 10. */
連線池最大連線數 public static final String DB_MAX_CONNECTIONS = "maxConnections"; /** * The maximum number of prepared statements that will be cached per connection in the pool. * Depending upon your JDBC Driver this may significantly help performance, or may slightly * hinder performance. * Default is 120, as Quartz uses over 100 unique statements. 0 disables the feature. */
每個連結最多快取多少個預編譯語句 public static final String DB_MAX_CACHED_STATEMENTS_PER_CONNECTION = "maxCachedStatementsPerConnection"; /** * The database sql query to execute every time a connection is returned * to the pool to ensure that it is still valid. */ 驗證連線是否可用的查詢語句 public static final String DB_VALIDATION_QUERY = "validationQuery"; /** * The number of seconds between tests of idle connections - only enabled * if the validation query property is set. Default is 50 seconds. */ 多久驗證空閒連線 public static final String DB_IDLE_VALIDATION_SECONDS = "idleConnectionValidationSeconds"; /** * Whether the database sql query to validate connections should be executed every time * a connection is retrieved from the pool to ensure that it is still valid. If false, * then validation will occur on check-in. Default is false. */ 是否每次從池中取連線時,驗證連線可用性 public static final String DB_VALIDATE_ON_CHECKOUT = "validateOnCheckout"; /** Discard connections after they have been idle this many seconds. 0 disables the feature. Default is 0.*/ 空閒連線超過多少秒丟棄 private static final String DB_DISCARD_IDLE_CONNECTIONS_SECONDS = "discardIdleConnectionsSeconds"; /** Default maximum number of database connections in the pool. */ 最大連線數 public static final int DEFAULT_DB_MAX_CONNECTIONS = 10; /** Default maximum number of database connections in the pool. */ 預設每個連結快取120個預編譯語句 public static final int DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION = 120;

quartz連線池配置對C3PO連線池配置進行了一些封裝, 留作記錄。

mysql 斷開連線可以通過設定 validateOnCheckout=true + validationQuery

或者設定discardIdleConnectionsSeconds 少於8小時解決。