Skip to content

Commit 7003e49

Browse files
author
lucaijun
committed
AJ-550: add the default value of pool connections
1 parent e0b0e5a commit 7003e49

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/com/xxdb/SimpleDBConnectionPool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ boolean isClosed() {
137137

138138
}
139139

140-
public class PoolEntry extends DBConnection {
140+
class PoolEntry extends DBConnection {
141141
AtomicBoolean inUse = new AtomicBoolean(false);
142142
String connectionName;
143143

144-
public PoolEntry(boolean useSSL, boolean compress, boolean usePython, String connectionName) {
144+
PoolEntry(boolean useSSL, boolean compress, boolean usePython, String connectionName) {
145145
super(false, useSSL, compress, usePython);
146146
this.connectionName = connectionName;
147147
}
148148

149-
public String getConnectionName() {
149+
String getConnectionName() {
150150
return connectionName;
151151
}
152152

153-
public boolean isIdle() {
153+
boolean isIdle() {
154154
return !this.inUse.get();
155155
}
156156

src/com/xxdb/SimpleDBConnectionPoolConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5+
56
import java.util.Objects;
67

78
public class SimpleDBConnectionPoolConfig {
@@ -138,8 +139,10 @@ public void validate() {
138139
password = getNullIfEmpty(password);
139140
if (Objects.isNull(password))
140141
log.warn("Logging in needs password.");
141-
if (initialPoolSize <= 0)
142-
throw new RuntimeException("The number of connection pools should be positive.");
142+
if (initialPoolSize <= 0) {
143+
initialPoolSize = 5;
144+
log.warn("The number of connection pools is invalid, use the default value 5.");
145+
}
143146
}
144147

145148
private static String getNullIfEmpty(String text) {

0 commit comments

Comments
 (0)