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.

Could someone please tell me how can i check if there is an active connection to sybaseIQ? I would like to perform a check before sending statements so that I have a chance to re-establish the connection in case it was lost.

I am using sacapi.h, sacapidll.cpp, sacapidll.h (SQL Anywhere C API which is layered on top of the DBLIB package and it was implemented with Embedded SQL).

I don't think callbacks are supported. I can't find documentation on sqlany_register_callback in the SybaseIQ documentation

asked 22 Oct '14, 12:33

lefteris's gravatar image

accept rate: 0%

edited 23 Oct '14, 04:32

It is not a Sybase IQ forum, however why could not you simply try to execute the statement. If it fails, then check the exception details, reconnect and then execute it again.

I am also not sure, but SybaseIQ probably provides a way to connect your callback handler with something. And if the connection is lost, the appropriate callback should be triggered.

(23 Oct '14, 02:11) Vlad
Replies hidden

What API / utility are you using?

(23 Oct '14, 03:27) Volker Barth

I can't find a SybaseIQ forum, and it seems the sybaseIQ connector for c++ is the same as the sqlanywhere connector. The header file of my connector defines a callback a function that returns an int and has no parameters, but there is no documentation on how it is used.

As for your suggestion of trial and error this is my current approach. I was just looking for something better.

(23 Oct '14, 04:38) lefteris
Comment Text Removed

I found only this article, but I do not know if you can use Embedded SQL in the code.

The function what you found is desribed here:

Unfortunately, I do not know if this info can help you for Sybase IQ.

(23 Oct '14, 05:08) Vlad

Ah, the C API - then it seems there's no official callback handling to get notified of dropped connections, as is possible in ESQL with db_register_a_callback (and type DB_CALLBACK_CONN_DROPPED). Via ODBC, you could use the SQL_ATTR_CONNECTION_DEAD connection attribute.

As the C API is based on ESQL and functions like sqlany_make_connection() are said to use a SQLCA, it might somehow be possible to access that to register a callback but that's very wild guessing on my part.

As Vlad, I would suggest to try to execute the statements and handle a disconnect error accordingly...

(23 Oct '14, 05:33) Volker Barth
Replies hidden

By the way, I thought a little bit, and I still agree with myself, that the exception checking, and repeating the connection is the best solution. There could be scenarios, when the connection is lost, none of packets are sent to the server (we assume that there is not keep-alive load), and in this case, the application will not be able to understand whether it was disconnected or not. Only when you send any request (it is better to send your particular SQL query), it will fail, and only this is the reliable way to determine that something was wrong.

You can use this approach for anything you want. Even to read packets through the power cable plugged to someone's washing machine :)

(23 Oct '14, 14:08) Vlad
showing 3 of 6 show all flat view

Hm, according to the v16 online docs, I stand corrected w.r.t. my statement the C API would not support a callback (I had just checked for v12.0.1, see my comment on the question):

Support for callbacks in the SQL Anywhere C API - Support for callbacks has been added to version 3 of the SQL Anywhere C API. The following function is now available when _SACAPI_VERSION is defined as 3.

sacapi_bool sqlany_register_callback( a_sqlany_connection * sqlany_conn, a_sqlany_callback_type index, SQLANY_CALLBACK_PARM callback );

This function can be used to register callback functions.

Note: That's what the docs say, I have not tested that myself...

And here's the whole story including a sample from the according CR note 738036 as released with v16.0.0.1522 and above, and these versions do contain an according sample "callback.cpp", too.

permanent link

answered 24 Oct '14, 08:38

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

edited 24 Oct '14, 08:47

unfortunately it's not supported in SybaseIQ :(

(30 Dec '14, 06:50) lefteris
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: 22 Oct '14, 12:33

question was seen: 2,798 times

last updated: 30 Dec '14, 06:50