1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-25 02:28:54 +00:00

连接池线程安全修正

This commit is contained in:
17jiong 2018-01-29 04:24:47 +08:00
parent 7a74e88cd1
commit ccedc8cfea

View File

@ -4,7 +4,7 @@ import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
public class MySQLCore implements DatabaseCore { public class MySQLCore implements DatabaseCore {
@ -12,7 +12,7 @@ public class MySQLCore implements DatabaseCore {
/** The connection properties... user, pass, autoReconnect.. */ /** The connection properties... user, pass, autoReconnect.. */
private Properties info; private Properties info;
private static final int MAX_CONNECTIONS = 8; private static final int MAX_CONNECTIONS = 8;
private static ArrayList<Connection> pool = new ArrayList<>(); private static final List<Connection> pool = Collections.synchronizedList(new ArrayList<Connection>());
public MySQLCore(String host, String user, String pass, String database, String port) { public MySQLCore(String host, String user, String pass, String database, String port) {
info = new Properties(); info = new Properties();