Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

timeout mechanism in database component

i have a database component called JDBCController. i need some suggestions on timeout mechanism in this component. this is the problem that i faced:

let say i do a select statement (using say method executeQuery in JDBCController) to select a record. suppose if that particular record is locked by some other applications and it is never release the lock. the method executeQuery will also be blocked indefinitely. as such, it is important to make sure that any request will not be blocked indefinitely.

any suggestions on this?
0
emily_my
Asked:
emily_my
  • 2
1 Solution
 
yongsingCommented:
You can use the setQueryTimeout() method in the Statement object to specify the number of seconds to wait for it to execute the query. If the limit is exceeded, an SQLException is thrown.
0
 
emily_myAuthor Commented:
thanks yongsing,

is this method really effective? do you think it is better to also configure on the database side?
0
 
yongsingCommented:
I have not tried it before, but you can always test it out. You can try configuring the database as well, but you should program your application such that it knows that a timeout has occurred when an SQLException is thrown.
0
 
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to yongsing

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now