1. Praveen Rajarao
  2. PowerBuilder
  3. Friday, 5 January 2018 20:58 PM UTC

Hello All,

I have a unique scenario where I have to capture (log) everytime my powerbuilder application loses its DB connection. 

App behavior - it will continue to show no signs of disconnection until the user tries to retrieve any data. Then it shows a message saying connection no longer available or unstable. 

However, is there a way to capture this at a global level? I have over 400 modules and I cannot include a code change in every datawindow dberror event. 

SystemError event does not trigger in this case. 

Any ideas?

Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 8 January 2018 16:22 PM UTC
  2. PowerBuilder
  3. # 1

I would consider using DBError event on the Transaction object.

See PB Help for details on Transaction class's DBError and SQLPreview. Help also describes how DBError and SQLPreview on DataWindow and DataStore interact with the Transaction's events.

Doing any active SQL statements in the SQLPreview will execute very often and potentially degrade your application's SQL performance.

 

HTH

/Michael

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 8 January 2018 14:59 PM UTC
  2. PowerBuilder
  3. # 2

Praveen -

    I think that you will need to do the following:

1. Put code in the ancestor object of the SQLPREVIEW event of SQLCA at the top of the event:

         "Select "1" from dual;            // Oracle code. Your database may vary.

2. If the select returns a valid value, you are connected. If not, you can return an error message, OR you can

a) initiate a counter

b) call an event or function to CONNECT to the database

c) retry the SQL from the SQLPREVIEW event

d) once the number of attempts equals then display an error message and stop processing.

 

Olan

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 5 January 2018 21:40 PM UTC
  2. PowerBuilder
  3. # 3

Hi Praveen;

  FYI: Since PB  version 12.5.x - the PB IDE has added new Events to the Transaction Object (TO) class. You probably know that object better as SQLCA. The TO class now has the DBNotofocation and DBError events in the latest PB releases. These events can be used at the DB Connection high-level to trap DBMS connectivity and DML issues. Also, a new DBHandle () method was also added. If this methods returns null, then DBMS connection has been lost. Using these new TO features can be used to intercept the type of problem you are outlining.

  Another alternative is to use a preemptive solution. That is for example ... use a TIMER object class that when the timer event fires, issues a non-intrusive DML command like "Select 1", Select @@version from dummy", etc that keeps the DBMS connection activity up so that the connection does not time out & then drop.

Food for thought.

Regards ... Chris

 

Comment
  1. Sivaprakash BKR
  2. Saturday, 6 January 2018 06:06 AM UTC
Hello,



Where and how can we write codes, (in dberror event) for default (sqlca) transaction object ?



Happiness Always

BKR Sivaprakash

  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 8 January 2018 03:48 AM UTC
FYI: You need to create your own NVUO inherited from the System Class Transaction Object. In your TO NVUO, you can then code those events and use its functions as required.

  1. Helpful
  1. Praveen Rajarao
  2. Monday, 8 January 2018 14:27 PM UTC
Thanks Chris for your responses. 



However, if I create a new NVUO from the transaction class object, will that have to be replaced with the existing transaction object I have? I already have a SQLCA object that is used all over the app, so if I create a new one, and write code in it's events, will that also require me to make a global change to use this "new" TO ? I am trying to get this done with minimum change from the app side. 



Your timer event hack sounds doable, but I "DO NOT" want to avoid the lost connectivity. I want to capture everytime it happens. 

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.