Hi, I'm trying to connect to a remote Sql Anywhere 12.01 database with the following code:
My console.log("Connected!") fires so I'm assuming that I've connected to the remote database? However, any query that I make results in this:
I looked through the error codes online and didn't find this one. Anyone know why I may be experiencing it and how I can fix it? |
The callback function should take two parameters: err and result. If err is undefined, then the connection succeeded, otherwise it indicates what error occurred. (In the case of connection, result will always be undefined.) Your code should look like this:
I had to change "let" to "var" to make the javascript run. Also, your Server connection parameter should be the server name, not the location. You should change "Server" to "Host" to indicate the hostname / port. Ahh I wondered about the initially.. I wasn't sure if the callback took any parameters. I just tried it with the parameters and I am now getting a new error:
Any idea what's going on there? This is the error that's returned from the conn.connect function
(24 Sep '15, 10:02)
swappticon
Replies hidden
Do you have the SQL Anywhere client software installed? dbcapi is part of that, and the node.js driver needs it.
(24 Sep '15, 10:11)
Graeme Perrow
I am not sure. What client software are you referring to? I originally tried installing the Sql Anywhere ODBC client but ran into some problems and decided to give the node module a try.
(24 Sep '15, 11:41)
swappticon
Replies hidden
The SQL Anywhere ODBC client would contain the files needed by the node.js driver. Did you run into problems installing it or using it? Is it still installed?
(24 Sep '15, 11:46)
Graeme Perrow
Ahh nvm. I just installed the client software and the sourced it. I forgot to run the source command when I did it earlier. I still haven't gotten the code to work, but I'm getting a database server not found error so maybe my code isn't the problem and it has more to do with the IP:Port I was given.
(24 Sep '15, 11:51)
swappticon
|
FWIW, as v17 has official Node.js support, you might have a look at the samples there, cf. Node.js application programming and the following pages.
Cool, I didn't know there was official support! I assume that, although the official support is for v17, I may be able to get it working with v12.01?