Postgres connect

  1. 5 years ago

    Joel_Eisenstat

    5 Sep 2018 User since 2016

    In CreoPlayer or Simulator when the iPad either sleeps or switches apps the Postgres connection to AWS is lost. Aside from rebooting the app I tried code to reconnect from the toolbar ;

    func onSuccess (db) {
    var alert = Alert("Connected", "You are connected to the Postgres cloud. ");
    alert.show();
    Odontogram.loadrecord();
    }
    func onError (db) {
    var alert = Alert("Error", "You are NOT connected to the Postgres cloud. ");
    alert.show();
    }
    PostgreSQL1.connect (onSuccess, onError) ;

    However this generates the error statement - You are NOT connected to the Postgres cloud.
    Is there a specific way to force a DB connection ?

    Thanks,

    Joel

  2. marco

    6 Sep 2018 Administrator User since 2016

    I would try add a check before your code, something like:

    if (PostgreSQL1.isConnected) PostgreSQL1.close();
    // then your code here
  3. Joel_Eisenstat

    6 Sep 2018 User since 2016

    Thanks Marco but I am confused about the logic. The db connection is already closed due to the device sleep , why force close if it is connected ? The above code is only used when there is a loss of connection message from the window construct method .

  4. marco

    6 Sep 2018 Administrator User since 2016

    Well, technically speaking the connection is not closed but freeze because the device has no way to send a close command back to the server. The trick I suggested you works fine in these cases.

  5. Joel_Eisenstat

    6 Sep 2018 User since 2016

    Thanks for the explanation

or Sign Up to reply!