Re: INT_EXIT error returned for msgno 20009

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Mon, 31 Oct 2011 13:43:47 -0400
"J.A." <[email protected]> wrote:

> I'm using Gnu C to attempt to connect to a MS Sqlserver 2008
> instance.  I have a freetds.conf file that successfully connects
> using tsql.  I checked the log and it was not present.  This leads me
> to believe the problem is my code is not using the config file (which
> apparently works).
> 
> how do I make my code use the config file?

Your freetds.conf is not read by dbinit(); it's consulted when you
call dbopen().  

> I am getting the following error when I run my code:
> FreeTDS: db-lib: exiting because client error handler returned
> INT_EXIT for msgno 2                  0009

Oof, what a little whitespace can do to the meaning of a message!
There is no msgno 2, which at first confused me.  But there is a msgno
20009: 

$ grep 20009 include/sybdb.h
#define SYBECONN        20009   /* Unable to connect socket -- SQL
		Server is unavailable or does not exist. */

So I think your error stems from dbopen(), not dbinit().  If you
install your error handler before calling dbopen() (as you should) you
can choose *not* to return INT_EXIT.  For more information, look for
the word "saith" in src/dblib/dblib.c.  

Try the same server with bsqldb or t0001.  These programs install an
error handler and print a more useful message, e.g.:

$ build/src/dblib/unittests/t0001 -S localhost
found localhost.FreeTDS for jkl in "../../../PWD"
About to logon as "jkl"
About to open "localhost"
DB-LIBRARY error (dberr 20009 (severity 9): "Unable to connect:
Adaptive Server is unavailable or does not exist"; oserr 61:
"Connection refused")

HTH.  

--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.