由于没有发现潜在的递归导致MySQL链接数溢出:MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connec
2014-03-24 16:25
453 查看
DAOProxy的代码:下面代码中红色高亮的就是出问题的地方,DAOFactory中会构造一个PersonDAOProxy,调用listPersons或者addPerson显然会导致递归,从而导致MySQL链接数溢出!将高亮处的代码修改为:dao.listPersons()、dao.addPerson(person)即可!
public class PersonDAOProxy implements IPersonDAO { private DatabaseConnection conn = null; private IPersonDAO dao = null; public PersonDAOProxy() throws NamingException, SQLException { conn = DatabaseConnection.newInstance(); dao = new PersonDAOImpl(conn.getConnection()); } @Override public List<Person> listPersons() throws SQLException { List<Person> persons = null; try { persons = DAOFactory.getIPersonDAOInstance().listPersons(); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } return persons; } @Override public void addPerson(Person person) throws SQLException { try { DAOFactory.getIPersonDAOInstance().addPerson(person); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } } }
相关文章推荐
- mysql: Data source rejected establishment of connection, message from server: "Too many connections"
- Mysql的错误,待解决[已解决]Data source rejected establishment of connection message from server: "Too many connections";
- MySQL Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"解决办法
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"解决办法
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection message from server: "Too many connections";
- Data source rejected establishment of connection, message from server: "Too many connections"
- Data source rejected establishment of connection, message from server: "Too many connections"
- (2) Data source rejected establishment of connection, message from server: "Too many connections"解决办
- Data source rejected establishment of connection, message from server: "Too
- message from server: "Host '192.168.6.68' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts
- mysql errors:message from server: "Host 'xxx' is blocked because of many connection errors; unblock