Host is blocked because of many connection errors;unblock with 'mysqladmin flush-hosts'

错误:Host is blocked because of many connection errors;unblock with 'mysqladmin flush-hosts'

原因:同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;

解决方法:我只说治本的

进入到数据库中 执行下面的命令

flush hosts;

c3p0 ThreadLocal 报错too many Connection

11-06

[code=java]public class DBUtil rn private static final ThreadLocal threadLocal = new ThreadLocal();rn rn /**rn * 取得数据库连接rn * @returnrn */rn public static Connection getConnection() rn Connection conn = null;rn conn = threadLocal.get();rn if(conn==null) rn conn = ConnectionManager.getInstance().getConn();rn threadLocal.set(conn);rn rn return conn;rn rnrn public static void closeConn() rn Connection conn = threadLocal.get();rn try rn if(conn!=null && !conn.isClosed()) rn conn.close();rn threadLocal.remove();rn rn catch (SQLException e) rn e.printStackTrace();rn rn rn rn public static void main(String args[]) rn for(int i=0;i<30;i++) rn Connection conn = getConnection();rn closeConn();rn System.out.println(i+"="+conn);rn rn rn[/code]rn[code=java]public class ConnectionManager rn private static ConnectionManager instance;rn private ConnectionManager()rn rn public synchronized Connection getConn() rn Connection conn = null;rn ComboPooledDataSource ds = new ComboPooledDataSource("userApp");rn rn try rn conn = ds.getConnection();rn catch (SQLException e) rn e.printStackTrace();rn rn return conn;rn rn rn public static ConnectionManager getInstance() rn if(instance==null) rn instance = new ConnectionManager();rn rn return instance;rn rn rn[/code]rnrnrn[color=#FF0000]c3p0配置[/color]:rn[code=text]com.mysql.jdbc.Driverrn jdbc:mysql://localhost:3306/examtest?useUnicode=true&characterEncoding=utf-8rn rootrn rootrn 10rn 30rn 10rn 10rn 40rn 100rn 5rn 1000rn 18000rn 25000code]rnrnrn一运行就只能取得10次连接,11以后就报错rnjava.sql.SQLException: Data source rejected establishment of connection, message from server: "Too many connections"rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1018)rn at com.mysql.jdbc.Connection.createNewIO(Connection.java:2568)rn at com.mysql.jdbc.Connection.(Connection.java:1485)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)rn at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.initializeAutomaticTestTable(C3P0PooledConnectionPoolManager.java:772)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.createPooledConnectionPool(C3P0PooledConnectionPoolManager.java:696)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:257)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:271)rn at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)rn at com.tom.util.ConnectionManager.getConn(ConnectionManager.java:17)rn at com.tom.util.DBUtil.getConnection(DBUtil.java:19)rn at com.tom.util.DBUtil.main(DBUtil.java:115)29=null

rmi问题:java.rmi.ConnectException: Connection refused to host: 172.20.5.180;

11-14

我在调试rmi的例程时,运行server端的程序时出现下面的错误:rnjava.rmi.ConnectException: Connection refused to host: 172.20.5.180;rnrn在 Naming.rebind("SimpleCounterServer",server);rnrn我的整个程序是(server):rn1 SimpleCounterServer.javarnpublic interface SimpleCounterServer extends java.rmi.Remotern public int getCount() throws java.rmi.RemoteException;rnrnrn2 SimpleCounterServerImpl.javarnimport java.rmi.*;rnimport java.rmi.server.UnicastRemoteObject;rnpublic class SimpleCounterServerImplrnextends UnicastRemoteObjectrnimplements SimpleCounterServerrnrn private int iCount;rn public SimpleCounterServerImpl() throws java.rmi.RemoteExceptionrn rn super();rn iCount = 0;rn rn public int getCount() throws RemoteExceptionrn rn return ++iCount;rn rnrn public static void main(String args[])rn rnrn if (System.getSecurityManager() == null) rn System.setSecurityManager(new RMISecurityManager());rn rn tryrn rn SimpleCounterServer server = new SimpleCounterServerImpl();rn System.out.println("SimpleCounterServer created");rn Naming.rebind("SimpleCounterServer",server);rn System.out.println("SimpleCounterServer registered");rn rn catch(RemoteException x)rn rn x.printStackTrace();rn rn catch(Exception x)rn rn x.printStackTrace();rn rn rnrnrn运行步骤是:rn1 javac *.javarn2 rmic SimpleCounterServerImplrn3 start rmiregistry 2001rn4 java -Djava.rmi.server.codebase=file:/f:\javaproject\rmi2\output\\/ -Djava.security.policy=java.policy SimpleCounterServerImplrnrn其中java.policy 是:rngrant rn permission java.net.SocketPermission "*:1024-65535",rn "connect,accept";rn permission java.io.FilePermissionrn "f:\\javaproject\\rmi2\\output\\-", "read";rn;rnrn不知问题出在哪里?rnrn谢谢了先

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试