1
我有Calc Runner类。在这个类中执行的4个方法没有公司数量的意思是这样的。如何实现连接池Multi_threading
for(long companyId : companies){
method1();
method2();
method3();
method4();
}
在这种方法正从DBStatic UTIL class.Like这 `
try {
synchronized (LOCK_OBJCT) {
if (_conn == null || _conn.isClosed()) {
Class.forName(DB_DRIVER);
logger.debug("Connecting to: " + DB_URL + "; as: " + DB_USERID);
_conn = DriverManager.getConnection(DB_URL, DB_USERID, DB_PASSWORD);
_conn.setAutoCommit(false);
}
else {
logger.debug("Connected to: " + DB_URL + "; as: " + DB_USERID);
}
}
} catch(ClassNotFoundException ce) {
logger.error("Error when obtaining JDBC driver.Exiting...", ce);
System.exit(1);
} catch(SQLException e) {
logger.error("Error when obtaining insight db conn: " + DB_URL + "; as: " + DB_USERID + " Exiting..." , e);
System.exit(1);
}
return _conn;
}`
我我们实施了多线程与ExcutiveService有4个线程池的连接。所有的方法都在线程中执行。 知道连接池的问题多线程无法正常工作。如何实现连接池的JDBC程序用于此多线程
我你实际上是使用'Java的ee'那么服务器管理这一切都为你 - 它只是需要一些配置。不需要重新创建这个特定的轮子 –