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

jarda_kotesovec
1214510
accept rate: 0%

There is a similar question, but for a different API and different server: http://sqlanywhere-forum.sap.com/questions/23217/sybaseiq-c-check-if-connected 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

JBSchueler
3.3k41564
accept rate: 19%

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×21

question asked: 07 Nov '14, 05:17

question was seen: 2,050 times

last updated: 10 Nov '14, 14:22