Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to wrap a method call with a timeout

807569Jul 12 2006 — edited Jul 12 2006
Hi all,

I have a situation in which I want to set a timeout for a method call.. or something like it.... eg.
public Connection getConnection(){
       Connection conn = DriverManager.getConnection("CONNSTRING","UID","PWD");
      return conn;
      // i wish to return null if the DriverManager call doesnt respond in 500 ms.
}
Any clues...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2006
Added on Jul 12 2006
2 comments
206 views