JDBC 数据库连接超时和查询超时控制问题

DriverManager.setLoginTimeout();
Statement.setQueryTimeout();
不起作用

[quote]不知道针对不同数据库jdbc驱动有没有统一的实现方法来控制连接超时? [/quote]应该没有统一的方法,这和数据库厂商的接口有关系,也没有形成统一的标准。

[quote]void setQueryTimeout(int seconds)
throws SQLException将驱动程序等待 Statement 对象执行的秒数设置为给定秒数。如果超过该限制,则抛出 SQLException。

参数:
seconds - 以秒为单位的查询超时限制;零表示没有任何限制
[/quote]
有没有把时间单位搞错了?

还与数据库的驱动程序有关系,你用的是什么驱动(jar包)?

[quote]Oracle JDBC does not support login timeouts. Calling the static DriverManager.setLoginTimeout() method will have no effect[/quote]