<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Log existing connection failures in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844492#M4875335</link>
    <description>&lt;P&gt;Just to understand: If a living connection goes down, wouldn't it be easier to log that on the client side?&lt;/P&gt;
&lt;P&gt;I don't know which API you are using. AFAIK, v11 has introduced a ODBC feature that might be of use in case you are using ODBC - from the "What's new / Programming interfaces" doc page:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;SQL_ATTR_CONNECTION_DEAD promptly detects dead connection&lt;/STRONG&gt;&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;Using ODBC's SQLGetConnectAttr call to get the SQL_ATTR_CONNECTION_DEAD attribute now gets the value SQL_CD_TRUE if the connection has been dropped even if no request has been made to the server since the connection was dropped. Determining if the connection has been dropped is done without making a request to the server, and the dropped connection is detected within a few seconds. The connection can be dropped for several reasons, for example, on an idle timeout. Before this change, SQL_ATTR_CONNECTION_DEAD only got the value SQL_CD_TRUE if the connection was disconnected or if ODBC driver made a request to the server (by calling SQLExecDirect for example) after the connection was dropped. See Getting connection attributes.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 22 Jan 2013 11:05:17 GMT</pubDate>
    <dc:creator>VolkerBarth</dc:creator>
    <dc:date>2013-01-22T11:05:17Z</dc:date>
    <item>
      <title>Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaq-p/13844486</link>
      <description>&lt;P&gt;SQL Anywhere 10 does not report database connection failures on the server when there is an underlying TCP/IP error.&lt;/P&gt;
&lt;P&gt;From looking through the docs I've found an auditing feature for successful and failed connection attempts. This falls short for what we need.&lt;/P&gt;
&lt;P&gt;Is it possible to enable a simple text based access log for the database similar to a HTTP server e.g. connection request - ip address - time, connection failure - ip address - time? It would also be good to have close connection requests.&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Shane&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 07:35:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaq-p/13844486</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-01-21T07:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844489#M4875332</link>
      <description>&lt;P&gt;The CREATE EVENT statement offers some functionality with the Connect, ConnectFailed and Disconnect event types, but it probably falls short of your needs as well. ODBC tracing and the dbsrv10 -z option are probably too extreme.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 08:21:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844489#M4875332</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2013-01-21T08:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844487#M4875330</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Anywhere 10 does not report database connection failures on the server when there is an underlying TCP/IP error.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps I'm misunderstanding, but I assume you're referring to a TCP/IP error between the client and the server (e.g. 'host not found', etc.?) If so, the server may not see all of these errors to be logged, since they are potentially happening at the network level. For these types of failures, you would be better to enable client-side logging (i.e. add &lt;A href="http://dcx.sybase.com/index.html#1001/en/dbdaen10/da-logfileparameter.html"&gt;"LogFile=clientlog.txt"&lt;/A&gt; to your connection string).&lt;/P&gt;
&lt;P&gt;Are you seeing these failures often / unexpectedly?&lt;/P&gt;
&lt;HR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Is it possible to enable a simple text based access log for the database similar to a HTTP server e.g. connection request - ip address - time, connection failure - ip address - time? It would also be good to have close connection requests.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See the '&lt;A href="http://dcx.sybase.com/index.html#1001/en/dbdaen10/da-z-database-dbengine.html"&gt;dbsrv10 -z -o output.txt&lt;/A&gt;' console log output switches.&lt;/P&gt;
&lt;P&gt;If you would like to create your own logging feature, you can likely do that via the '&lt;A href="http://dcx.sybase.com/index.html#1001/en/dbdaen10/da-events-events.html"&gt;Connect / Disconnect&lt;/A&gt;' system events and the &lt;CODE&gt;CONNECTION_PROPERTY('AppInfo')&lt;/CODE&gt;,   &lt;CODE&gt;CONNECTION_PROPERTY('CommLink')&lt;/CODE&gt;, and &lt;CODE&gt;CONNECTION_PROPERTY('NodeAddr')&lt;/CODE&gt; &lt;A href="http://dcx.sybase.com/index.html#1001/en/dbdaen10/da-connection-properties.html"&gt;connection properties&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 08:45:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844487#M4875330</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2013-01-21T08:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844490#M4875333</link>
      <description>&lt;P&gt;Note that for failing connection attempts due to network errors, the ConnectFailed event won't usually be able to log these ... simply as the server won't notice such an attempt at all (as Jeff and Breck have stated, too)...&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 09:17:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844490#M4875333</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-01-21T09:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844491#M4875334</link>
      <description>&lt;P&gt;Requiring extra logging or an event is overkill, IMHO. It would be nice if the client posted the OS-level/TCP-level error code plus a human-readable description.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 10:04:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844491#M4875334</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-01-22T10:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844488#M4875331</link>
      <description>&lt;P&gt;Thanks for taking the time to respond.&lt;/P&gt;
&lt;P&gt;When I mentioned TCP/IP error it was in the context of an active connection to the database that suffers from a network outage.&lt;/P&gt;
&lt;P&gt;Our application using connection pooling which involves the re-use of the same connection many times over a prolonged period. If the network goes down between our application host and database host briefly I would like to see an appropriate error in the database logs.&lt;/P&gt;
&lt;P&gt;Since this is an intermittent problem in our production environment it is not suitable for use to run the database in diagnostic mode using the -z server option. I understand that this has a major affect on performance.&lt;/P&gt;
&lt;P&gt;Unfortunately the connection events only show connection attempts rathen than the health of existing connections.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 10:41:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844488#M4875331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-01-22T10:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844492#M4875335</link>
      <description>&lt;P&gt;Just to understand: If a living connection goes down, wouldn't it be easier to log that on the client side?&lt;/P&gt;
&lt;P&gt;I don't know which API you are using. AFAIK, v11 has introduced a ODBC feature that might be of use in case you are using ODBC - from the "What's new / Programming interfaces" doc page:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;SQL_ATTR_CONNECTION_DEAD promptly detects dead connection&lt;/STRONG&gt;&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;Using ODBC's SQLGetConnectAttr call to get the SQL_ATTR_CONNECTION_DEAD attribute now gets the value SQL_CD_TRUE if the connection has been dropped even if no request has been made to the server since the connection was dropped. Determining if the connection has been dropped is done without making a request to the server, and the dropped connection is detected within a few seconds. The connection can be dropped for several reasons, for example, on an idle timeout. Before this change, SQL_ATTR_CONNECTION_DEAD only got the value SQL_CD_TRUE if the connection was disconnected or if ODBC driver made a request to the server (by calling SQLExecDirect for example) after the connection was dropped. See Getting connection attributes.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 22 Jan 2013 11:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844492#M4875335</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-01-22T11:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Log existing connection failures</title>
      <link>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844493#M4875336</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt; If the network goes down between our application host and database host briefly I would like to see an appropriate error in the database logs.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I believe you really mean "application logs" here, not database server logs. Again, the failure to contact the server over TCP/IP from the client needs to be logged on the client side - the database server can't log a connection failure that it can't see.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;Beyond the "LOG=" client log connection string option that I mentioned previously, depending on which API you're using (as Volker indicated), you can usually 'catch' some kind of exception / log an error upon a failed connection attempt from the client side in the API layer, and then "log" it somewhere in your application.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;e.g. ADO.NET C# code:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;SAConnection&lt;/SPAN&gt; &lt;SPAN class="n"&gt;conn&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="k"&gt;new&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SAConnection&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"Data Source=SQL Anywhere 12 Demo;UID=DBA;PWD=sql"&lt;/SPAN&gt; &lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

&lt;SPAN class="n"&gt;try&lt;/SPAN&gt; &lt;SPAN class="p"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;conn&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Open&lt;/SPAN&gt;&lt;SPAN class="p"&gt;();&lt;/SPAN&gt;
    &lt;SPAN class="o"&gt;...&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;}&lt;/SPAN&gt; &lt;SPAN class="n"&gt;catch&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SAException&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ex&lt;/SPAN&gt;&lt;SPAN class="p"&gt;){&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;MessageBox&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Show&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ex&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Errors&lt;/SPAN&gt;&lt;SPAN class="p"&gt;[&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;0&lt;/SPAN&gt;&lt;SPAN class="p"&gt;]&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Message&lt;/SPAN&gt; &lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="sr"&gt;//&lt;/SPAN&gt; &lt;SPAN class="k"&gt;do&lt;/SPAN&gt; &lt;SPAN class="n"&gt;more&lt;/SPAN&gt; &lt;SPAN class="n"&gt;application&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;log&lt;/SPAN&gt; &lt;SPAN class="n"&gt;error&lt;/SPAN&gt; &lt;SPAN class="n"&gt;logging&lt;/SPAN&gt; &lt;SPAN class="n"&gt;here&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;}&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;e.g JDBC code:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;try&lt;/SPAN&gt; &lt;SPAN class="p"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;Connection&lt;/SPAN&gt; &lt;SPAN class="n"&gt;conn&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DriverManager&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;getConnection&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"jdbc:sqlanywhere:uid=DBA;pwd=sql"&lt;/SPAN&gt; &lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="o"&gt;...&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;}&lt;/SPAN&gt; &lt;SPAN class="n"&gt;catch&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SQLException&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sqe&lt;/SPAN&gt;&lt;SPAN class="p"&gt;){&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;System&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;err&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;println&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s"&gt;"Error: "&lt;/SPAN&gt; &lt;SPAN class="o"&gt;+&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sqe&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;toString&lt;/SPAN&gt;&lt;SPAN class="p"&gt;()&lt;/SPAN&gt; &lt;SPAN class="o"&gt;+&lt;/SPAN&gt; &lt;SPAN class="s"&gt;", sqlstate = "&lt;/SPAN&gt; &lt;SPAN class="o"&gt;+&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sqe&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;getSQLState&lt;/SPAN&gt;&lt;SPAN class="p"&gt;());&lt;/SPAN&gt;
    &lt;SPAN class="sr"&gt;//&lt;/SPAN&gt; &lt;SPAN class="k"&gt;do&lt;/SPAN&gt; &lt;SPAN class="n"&gt;more&lt;/SPAN&gt; &lt;SPAN class="n"&gt;application&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;log&lt;/SPAN&gt; &lt;SPAN class="n"&gt;error&lt;/SPAN&gt; &lt;SPAN class="n"&gt;logging&lt;/SPAN&gt; &lt;SPAN class="n"&gt;here&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;}&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 Jan 2013 12:43:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/log-existing-connection-failures/qaa-p/13844493#M4875336</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2013-01-22T12:43:43Z</dc:date>
    </item>
  </channel>
</rss>

