Clearquest Database Timeout
I have a tool that is setup to query our Clearquest Database to return information to the user automatically every 9000 milliseconds. I came in today and the connection had timed out over the weekend, I found in the oSession object a "check heartbeat" function, but I'm not sure that is what I want to use to determine if i need to 开发者_如何学JAVA"re-login", I saw a db.timeoutinterval, but I can't seem to find any good reference on how to call it, since the oSession Object doesn't actually call it, and any references in the API guide mention it with regard to actually creating the db using the adminsession object. What "object" do I need to create to access the timeout interval and how? Thank you for the help! Or is it better to use the "check heartbeat function" and will it return a true or false depending on current state of login?
Well to make a long story short, I don't have a clue what checkheartbeat actually does, but before I try to do some clearquest stuff (queries and the like) I make a call with my oSession object. I'm not certain if the checkheartbeat will return a boolean if the session has expired, or not, so I put it in a try catch block
Try
If Not oSession.CheckHeartbeat Then
'insert login function here
MsgBox("Had to re-login false Heartbeat")
End If
Catch ex As Exception
'insert login function here
MsgBox("Had to re-login Exception style")
End Try
Thus far I haven't had a timeout, so I've been unable to truly test this out. If the time comes that I have a timeout. Then I'll update what I find out.
CheckHeartbeat is for licenses only. It does not affect or check session timeout. CheckHearbeat will send a heartbeat to the license server telling it that the license is still in use. The only way to see if a session has timed out is to try something and see if an error occurs.
If you are planning to perform CQ operations between lengthy intervals, the best thing to do is logout and then login again when you need to redo the operation. This frees up the Db connection immediately.
Also note that you can change the database timeout, which may not be recommended if you want to ensure that connections aren't held too long. The property to change the database timeout is on the Database object and its called TimeoutInterval. Then you need to call ApplyPropertyChanges to apply them to the database. The change is permanent, that is, all future sessions use the new timeout. You change it again at any time.
精彩评论