|
20 | 20 | import de.fraunhofer.iosb.ilt.settings.ConfigDefaults; |
21 | 21 | import de.fraunhofer.iosb.ilt.settings.Settings; |
22 | 22 | import de.fraunhofer.iosb.ilt.settings.annotation.DefaultValue; |
| 23 | +import de.fraunhofer.iosb.ilt.settings.annotation.DefaultValueBoolean; |
| 24 | +import de.fraunhofer.iosb.ilt.settings.annotation.DefaultValueInt; |
23 | 25 | import de.fraunhofer.iosb.ilt.settings.annotation.SensitiveValue; |
24 | 26 | import java.sql.Connection; |
25 | 27 | import java.sql.DriverManager; |
@@ -68,13 +70,13 @@ public class ConnectionUtils implements ConfigDefaults { |
68 | 70 | public static final String TAG_DB_MINIDLE = "db.conn.idle.min"; |
69 | 71 |
|
70 | 72 | // Connection validation settings |
71 | | - @DefaultValue("false") |
| 73 | + @DefaultValueBoolean(false) |
72 | 74 | public static final String TAG_DB_TEST_ON_BORROW = "db.conn.testOnBorrow"; |
73 | | - @DefaultValue("false") |
| 75 | + @DefaultValueBoolean(false) |
74 | 76 | public static final String TAG_DB_TEST_WHILE_IDLE = "db.conn.testWhileIdle"; |
75 | 77 | @DefaultValue("") |
76 | 78 | public static final String TAG_DB_VALIDATION_QUERY = "db.conn.validationQuery"; |
77 | | - @DefaultValue("0") |
| 79 | + @DefaultValueInt(0) |
78 | 80 | public static final String TAG_DB_EVICTION_INTERVAL = "db.conn.timeBetweenEvictionRunsMillis"; |
79 | 81 |
|
80 | 82 | /** |
@@ -142,16 +144,15 @@ private static DataSource setupBasicDataSource(Settings settings) { |
142 | 144 | ds.setMaxTotal(settings.getInt(TAG_DB_MAXCONN, ds.getMaxTotal())); |
143 | 145 | ds.setMinIdle(settings.getInt(TAG_DB_MINIDLE, ds.getMinIdle())); |
144 | 146 |
|
145 | | - // Connection validation settings (default false for backward compatibility) |
146 | | - ds.setTestOnBorrow(settings.getBoolean(TAG_DB_TEST_ON_BORROW, false)); |
147 | | - ds.setTestWhileIdle(settings.getBoolean(TAG_DB_TEST_WHILE_IDLE, false)); |
| 147 | + ds.setTestOnBorrow(settings.getBoolean(TAG_DB_TEST_ON_BORROW, ConnectionUtils.class)); |
| 148 | + ds.setTestWhileIdle(settings.getBoolean(TAG_DB_TEST_WHILE_IDLE, ConnectionUtils.class)); |
148 | 149 |
|
149 | 150 | String validationQuery = settings.get(TAG_DB_VALIDATION_QUERY, ConnectionUtils.class); |
150 | 151 | if (!validationQuery.isEmpty()) { |
151 | 152 | ds.setValidationQuery(validationQuery); |
152 | 153 | } |
153 | 154 |
|
154 | | - long evictionInterval = settings.getLong(TAG_DB_EVICTION_INTERVAL, 0L); |
| 155 | + long evictionInterval = settings.getLong(TAG_DB_EVICTION_INTERVAL, ConnectionUtils.class); |
155 | 156 | if (evictionInterval > 0) { |
156 | 157 | ds.setTimeBetweenEvictionRunsMillis(evictionInterval); |
157 | 158 | } |
|
0 commit comments