Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.


I am new to using sqlanywhere and I am seeing this issue. When I try to connect to sybase, I am seeing this error:

[Error: Code: -2004 Msg: Can't initialize DBCAPI]

I can connect with other clients like RazorSQL. I am running this code on a mac and our servers for prod will be Unix. I am just trying to connect at this point. I searched for information on this and I cannot find any.

Thanks in advance

asked 23 Mar '15, 13:20

bradenpowers's gravatar image

accept rate: 0%

edited 23 Mar '15, 13:23

You might have ran into the same problem as noted on another thread Running dbcapi examples on mac osx?. The -2004 is an error coming from the OSX loader and not native to SQL Anywhere so it does sound like a DYLD_LIBRARY_PATH related problem.

If this does not help, you might want to show the versions being used, mention your development environment, and supply some more context.

(23 Mar '15, 13:58) Nick Elson S...

I will take a look

(23 Mar '15, 14:04) bradenpowers

That really didn't help me. This is a node project that I am starting. I am running yosemite, node version is v0.10.26 and the version of sqlanywhere I am running is 1.0.3. I have the XCode developer tools installed. This is the code I am using:

var sqlanywhere = require('sqlanywhere');

var conn = sqlanywhere.createConnection();

var conn_params = { Host : 'My_IP:MY_port', UserId : 'user_id', Password: 'password', DatabaseName: db_name', ServerName: 'server_name' };

conn.connect(conn_params, function(err) { if( err ) { console.log( err ); return; } console.log( "Connected." );

conn.exec( "SELECT * from Table", function(err, result) {
    if ( err ) {
        console.log( err );
    console.log( "Result: ", result );

conn.disconnect( function( err ) {
console.log( "Disconnected." );


(23 Mar '15, 14:25) bradenpowers
Replies hidden

That really didn't help me.

So you can use DBPING or other utilities to connect to your database, as was suggested as test in that other FAQ?

(23 Mar '15, 15:35) Volker Barth

I don't have that command. I did ping the database via ip successfully. I can also connect to it using the client RazorSQL and run queries against the database that I need to connect to.

(23 Mar '15, 16:04) bradenpowers
Comment Text Removed

So I found the sql anywhere tools and downloaded them. I ran DBPING and this is what I received:

Connection was dropped (may not be a SQL Anywhere server)

That is correct. This is a sybase server. Is there anything else I can do?

(23 Mar '15, 17:29) bradenpowers
Replies hidden

Hm, what exact SAP Sybase DBMS are you using - SQL Anywhere, ASE, Sybase IQ, ...?

If that is not SQL Anywhere then you may better ask in a different location, cf. the FAQ.

(24 Mar '15, 04:56) Volker Barth

I'm experiencing exactly the same thing you are. Have you figured this out yet?

(30 Mar '15, 21:49) hnilsen

I don't yet believe the dbping error is related to the first issue. FWIW I can reproduce that error dbpinging, say, my IIS server as in dbping -c "host=localhost:80" and you should be able to get the same error dbpinging any open listener on any IP address that is not SQL Anywhere. That just means your HOST=<ip>:<port> is wrong and it is not the same thing as being unable to load a dynamic library (as in your first case).

If you make no progress with this you may want to open up a support incident . . .

Do at least identify the version and build of SQL Anywhere you are using.

(31 Mar '15, 11:37) Nick Elson S...
More comments hidden
showing 4 of 9 show all flat view

Based on your discussion with Volker and Nick, it appears as though you are not using a SQL Anywhere server. The sqlanywhere node.js driver is specific to the SQL Anywhere server, so if your backend is not SQL Anywhere, then you should look for another driver.

Additionally, the node.js driver uses the DBCAPI library to communicate. The DBCAPI library needs to be able to load the SQL Anywhere client library (e.g. libdblib16_r.dylib). It requires that you have a SQL Anywhere client installation on the machine and that your DYLD_LIBRARY_PATH references the lib64 directory within that installation. e.g. if your installation is in /opt/sqlanywhere16, set DYLD_LIBRARY_PATH=/opt/sqlanywhere16/System/lib64. The other thread that Nick referenced in his comment deals with how to make sure this is set within XCode.

If you believe you have met all of the above requirements, then please let us know the version of the SQL Anywhere server to which you are connecting, and the version of the SQL Anywhere client libraries you have installed. You have already mentioned the version of node.js driver.

permanent link

answered 31 Mar '15, 11:10

Phil%20Mitchell's gravatar image

Phil Mitchell
accept rate: 27%

edited 31 Mar '15, 11:12

I think the problem lies with the DBCAPI library. I'm trying to start dbping, and get this result: ./dbping: error while loading shared libraries: cannot open shared object file: No such file or directory

Don't really know how to solve that.

(31 Mar '15, 14:16) hnilsen

dbping does not use DBCAPI. libdblib16_r.dylib needs to be accessible through your DYLD_LIBRARY_PATH. You need to set up your environment before you can run.

Based on you writing it appears that you are on another UNIX platform (perhaps Linux; the original question was on Mac). The name of the environment variable differs based on the platform. For example, on Linux, it will be LD_LIBRARY_PATH. If you are getting that error message on Mac, then that is a problem.

For help running the command-line utilities on UNIX and Mac OS X, please refer to the SQL Anywhere documentation:

(31 Mar '15, 14:32) Phil Mitchell

LD_LIBRARY_PATH was corrent, thanks - I now get a more reasonable error: [Error: Code: -100 Msg: Database server not found] - so I just need to figure out why I'm getting this instead :-) Thanks for your help.

(31 Mar '15, 17:48) hnilsen
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: 23 Mar '15, 13:20

question was seen: 4,857 times

last updated: 31 Mar '15, 17:48