there is still a connection

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

there is still a connection

Post by sinys » Wed 28 Nov 2012 05:23

when I don`t use the programm for a long time the session on server is broken and when I`m trying to access the session it could call the event like "TDataModule1.OraSes1ConnectionLost".
I need to close the programm and for closing it I do this:
OraSes1.Rollback;
OraSes1.Disconnect;
Sometimes these calles TDataModule1.OraSes1ConnectionLost and as a consequence the reconnection. Reconnection takes lots of time.
Is any quick way to find out about the session activity and avoid the reconnection in closing of session?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: there is still a connection

Post by AlexP » Wed 28 Nov 2012 12:15

Hello,

To check the current session, you can use the TOraSession.Ping method, having wrapped it into a Try...Except block, and, in case if execution of this method raises an error, execute the needed code in the except block. This method won't call the OnConnectionLost event independently on connection settings.

sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Re: there is still a connection

Post by sinys » Wed 28 Nov 2012 16:02

Method "Ping" the fastest?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: there is still a connection

Post by AlexP » Thu 29 Nov 2012 08:49

Hello,

Yes, it is the easiest way to define server availability and avoid the OnConnectionLost event

sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Re: there is still a connection

Post by sinys » Thu 29 Nov 2012 15:42

If user doesn`t use the program for a long time, he will get the message from the server that the connection is lost.
We get out from this situation using a timer and every minute send select * from dual to the session on the server didn`t close and still has been up to date.
May be a command Ping will do the same, but would it be faster and less overload the server?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: there is still a connection

Post by AlexP » Fri 30 Nov 2012 10:04

Hello,

Independently on how you execute the query (Open or Execute), server generates and returns ResultSet even for a query "SELECT * FROM DUAL", that requires definite time, the Ping command doesn't return ResultSet, therefore it is executed faster.

sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Re: there is still a connection

Post by sinys » Fri 30 Nov 2012 13:50

Would the ping command keep the session in active state on the server?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: there is still a connection

Post by AlexP » Mon 03 Dec 2012 15:36

Hello,

Yes, running the Ping command keeps the session in active.

Post Reply