MyBatis鏈接池參數

properties = new HashMap<>();mysql

properties.put("driverClassName", "com.mysql.jdbc.Driver");//驅動方式sql

properties.put("validationQuery", "select 1");//心跳檢測語句數據庫

properties.put("maxTotal", "30");//最大30緩存

properties.put("minIdle", "2");//最小空閒鏈接數日誌

properties.put("maxIdle", "10");//最大空閒鏈接數對象

properties.put("maxWaitMillis", "10000");//最大等待時間rem

properties.put("testOnBorrow", "false");//true 表示取鏈接發送一次心跳檢測it

properties.put("testOnReturn", "false");//true 表示鏈接放回鏈接此發送一次心跳檢測io

properties.put("testWhileIdle", "false");//true 空閒時候心跳檢測table

properties.put("removeAbandonedOnBorrow", "false");// true 獲取鏈接時判斷當時是否有超時的鏈接並強制回收放回鏈接池

properties.put("removeAbandonedOnMaintenance", "true");//ture 空閒是判斷當時是否有超時的鏈接並強制回收放回鏈接池

properties.put("removeAbandonedTimeout", "30");//鏈接超時時間

properties.put("logAbandoned", "true");//強制回收鏈接是否打印日誌

properties.put("timeBetweenEvictionRunsMillis", "30000");//空閒心跳檢測時間

properties.put("softMinEvictableIdleTimeMillis", "60000");//鏈接池中鏈接空閒時長超過該時長則強制關閉鏈接,單鏈接小於等於最小空閒鏈接數則不強制關閉

//properties.put("minEvictableIdleTimeMillis", "60000");//鏈接池中鏈接空閒時長超過該時長則強制關閉鏈接,會所有關閉鏈接 故通常不設

properties.put("logExpiredConnections", "false");//softMinEvictableIdleTimeMillis該設置觸發是否打印日誌

properties.put("poolPreparedStatements", "false");//true 緩存jdbc PreparedStatement對象

properties.put("defaultAutoCommit", "false");//默認是否自動提交,每次數據庫操做都會提交,注意和enableAutoCommitOnReturn參數的差異

properties.put("enableAutoCommitOnReturn", "true");//true 鏈接放回鏈接池的時候提交

properties.put("rollbackOnReturn", "true");//true 放回鏈接池時候回滾,主要是針對數據庫沒有commit時候回滾數據

相關文章
相關標籤/搜索