DriverManager.setLoginTimeout(1);
con = DriverManager.getConnection(url, prop);试了这个也没有效果…还是等很长时间才显示错误

解决方案 »

  1.   

    我记的是conn.setTimeOut()呀,你试试
      

  2.   

    setQueryTimeout
    void setQueryTimeout(int seconds)
                         throws SQLException将驱动程序等待 Statement 对象执行的秒数设置为给定秒数。如果超过该限制,则抛出 SQLException。 参数:
    seconds - 以秒为单位的查询超时限制;零表示没有任何限制 
    抛出: 
    SQLException - 如果发生数据库访问错误或者不满足条件 seconds >= 0
      

  3.   


    Connection con = DriverManager.getConnection(url, prop);
    这里 url 可能已经不能连接, 不是在 query 部分conn.setTimeOut()conn 都没有成功建立, 还是不能set time out