Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Once my app starts I will try to connect and I get err if connection is not established, which is great.

var conn = sqlanywhere.createConnection();
conn.connect(connParams, function (err) ...

I keep persistent connection in my Node.js app and I struggle how to handle when connection is terminated later, when sql server is restarted or something. I get errors from conn.exec, but it would be very useful if I could check before using exec that connection has not been terminated so I can handle reconnect logic. I did not find any property or function on conn that would give me current status. Any suggestions how to detect when connection is terminated?

Thank you.

asked 07 Nov '14, 05:17

jarda_kotesovec's gravatar image

accept rate: 0%

There is a similar question, but for a different API and different server: Maybe this is what you need!

(08 Nov '14, 08:12) Vlad

Unlike ADO.NET, there are no properties associated with the connection (i.e., there is no conn.State to test).

In this case, a liveness test can be implemented by executing a "SELECT 1" which will always succeed if a connection is present and fail when it isn't. But then you didn't want to use exec.

permanent link

answered 10 Nov '14, 14:22

JBSchueler's gravatar image

accept rate: 20%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 07 Nov '14, 05:17

question was seen: 2,126 times

last updated: 10 Nov '14, 14:22