Commit 9d347b7e authored by 赵建伟's avatar 赵建伟

update logs

parent 1e4d4db4
...@@ -16,7 +16,7 @@ public class JdbcConnectPool { ...@@ -16,7 +16,7 @@ public class JdbcConnectPool {
private static final Logger logger = LoggerFactory.getLogger(JdbcConnectPool.class); private static final Logger logger = LoggerFactory.getLogger(JdbcConnectPool.class);
private static Properties prop; private static Properties prop;
private static int currentsize = 0; private static int requestCount = 0;
private static LinkedList<Connection> connList = new LinkedList<Connection>(); private static LinkedList<Connection> connList = new LinkedList<Connection>();
static { static {
...@@ -29,7 +29,7 @@ public class JdbcConnectPool { ...@@ -29,7 +29,7 @@ public class JdbcConnectPool {
for (int i = 0; i < Integer.valueOf(prop.getProperty("initSize")); i++) { for (int i = 0; i < Integer.valueOf(prop.getProperty("initSize")); i++) {
Connection connection = createConnect(); Connection connection = createConnect();
connList.add(connection); connList.add(connection);
currentsize++; //currentsize++;
} }
} }
...@@ -40,19 +40,21 @@ public class JdbcConnectPool { ...@@ -40,19 +40,21 @@ public class JdbcConnectPool {
*/ */
public static Connection getConnect() { public static Connection getConnect() {
Connection connection = null; Connection connection = null;
if (connList.size() > 0) { int connSize = connList.size();
if (connSize > 0) {
connection = connList.getFirst(); connection = connList.getFirst();
connList.removeFirst(); connList.removeFirst();
currentsize--; //currentsize--;
} else{ } else{
while(currentsize < Integer.valueOf(prop.getProperty("maxSize"))){ while(connSize < Integer.valueOf(prop.getProperty("maxSize"))){
connList.addLast(createConnect()); connList.addLast(createConnect());
currentsize++; //currentsize++;
} }
connection = getConnect(); connection = getConnect();
} }
logger.info("Current pool size : {}",currentsize); requestCount ++;
logger.info("connList size : {}",connList.size()); logger.info("requestCount : {}",requestCount);
logger.info("connList size : {}",connSize);
return connection; return connection;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment