本文介绍了在Linux平台上从Node.js连接到DB2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从node.js应用程序连接到DB2。我决定使用。安装 db2.js 的说明首先告诉您如下安装 node-gyp



sudo npm install -g node-gyp



对我来说。

然后我尝试用这个命令安装db2.js:



sudo npm install -g db2



然后我得到这个错误:

  ... 
cc1plus:错误:无法识别的命令行选项-std = c ++ 0x
...
gyp ERR! node -v v0.10.9
gyp ERR! node-gyp -v v0.9.6

查看,它说我需要gcc。在我的系统上在gcc上做一个人显示, -std 选项只支持一些真正的旧编译器,例如 c ++ 98 4.1.2 20080704(Red Hat 4.1.2-50) gnu99



所以我有几个问题。有没有另一种方法连接到db2从节点?如果我继续使用db2.js,那么我现在需要做什么,升级我的gcc或安装一个 c ++ 0x 编译器? (我认为是C ++版本11)。



祝你好运。



编辑:



我在我的linux服务器上升级gcc时遇到问题,所以我尝试在我的树莓派安装作为测试:

  sudo npm install -g node-gyp 
cd / usr / lib / node_modules
sudo git clone https://github.com/herzi/db2.js.git
sudo node-gyp configure
sudo node-gyp build

得到此错误:

 在从../src/binding.cc:3:0:
中包含的文件中。 ./src/connection.hh:6:20:致命错误:sqlcli.h:没有这样的文件或目录
编译终止。



我猜这是DB2客户端头文件,所以我可能还需要安装。 p>

EDIT 2



我在我的系统上安装了 gcc 一个不同的目录。然后我改变了 / usr / bin gcc g ++ 指向我的新gcc和g ++(在gcc内)。现在我得到了相同的 sqlcli.h 错误,我得到我的pi。获得DB2客户端的时间。



Meh。我有db2客户端9.1.2。我需要9.7根据一些搜索在db2 binding.gyp 文件。



编辑3



我安装了IBM Data Server Runtime Client V9.7,但在<$ c $中没有 sqlcli.h c> /opt/IBM/db2/V9.7/include 文件夹!我有一个V9.1.3在不同的机器,有一个包含文件夹。因此,我安装了帮助我。现在我从node-gyp生成一个错误, strcmp 没有声明。我打赌我需要设置一个lib包含或节点环境var。

解决方案

你可以添加包含文件的字符串函数 #include< cstring> )转换为 src / connection.cc 。这应该启用字符串函数;也许你需要用 strcmp()替换 std :: strcmp()


I am trying to connect to DB2 from a node.js application. I have decided to use the db2 node module. The instructions for installing db2.js first tell you to install node-gyp like this:

sudo npm install -g node-gyp

That seems to have worked for me.
Then I try to install db2.js with this command:

sudo npm install -g db2

Then I get this error:

...
cc1plus: error: unrecognized command line option "-std=c++0x"
...
gyp ERR! node -v v0.10.9
gyp ERR! node-gyp -v v0.9.6

Looking at the prereqs for node-gyp, it says I need gcc. Doing a man on gcc on my system shows that the -std option is only supporting some really old compilers like c++98, gnu99, etc. I have gcc version 4.1.2 20080704 (Red Hat 4.1.2-50).

So I have a few questions. Is there another way to connect to db2 from node? If I continue with db2.js, then what do I need to do now, upgrade my gcc or install a c++0x compiler? (I think that's C++ version 11).

Wish me luck.

EDIT:

I am having trouble upgrading gcc on my linux server, so I tried installing on my raspberry pi as a test:

sudo npm install -g node-gyp
cd /usr/lib/node_modules
sudo git clone https://github.com/herzi/db2.js.git
sudo node-gyp configure
sudo node-gyp build

On the last command I get this error:

In file included from ../src/binding.cc:3:0:
../src/connection.hh:6:20: fatal error: sqlcli.h: No such file or directory
compilation terminated.

I am guessing that's the DB2 Client header file, so I probably need to install that also.

EDIT 2

I installed gcc on my system in a different directory. Then I changed the symlinks in /usr/bin for gcc and g++ to point at my new gcc and g++ (inside gcc). Now I get the same sqlcli.h error that I get on my pi. Time to get the DB2 Client.

Meh. I have db2 client 9.1.2. I need 9.7 according to some searching in the db2 binding.gyp file.

EDIT 3

I installed "IBM Data Server Runtime Client V9.7", but it does not have sqlcli.h in the /opt/IBM/db2/V9.7/include folder! I have a V9.1.3 on a different machine which does have a include folder. So I installed "IBM Data Server Client 9.7" using an old blog post of mine to help me. Now I am getting an error from the node-gyp build that strcmp was not declared. I bet I need to set a lib include or node environment var.

解决方案

You can add the include files for string functions (e.g. #include <cstring>) into src/connection.cc. That should enable the string functions; maybe you need to replace strcmp() with std::strcmp() then.

这篇关于在Linux平台上从Node.js连接到DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 13:24