在 Linux 平台上从 Node.js 连接到 DB2

Connecting to DB2 from Node.js on Linux-platform(在 Linux 平台上从 Node.js 连接到 DB2)

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

问题描述

我正在尝试从 node.js 应用程序连接到 DB2.我决定使用 db2 节点模块.安装 db2.js 的说明首先告诉你像这样安装 node-gyp:

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

这似乎对我有用.
然后我尝试使用以下命令安装 db2.js:

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

sudo npm install -g db2

然后我得到这个错误:

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

查看 node-gyp 的先决条件,它说我需要 gcc.在我的系统上对 gcc 进行操作表明 -std 选项仅支持一些非常老的编译器,例如 c++98gnu99、等等.我有 gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-50).

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).

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

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).

祝我好运.

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

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.

我猜那是 DB2 Client 头文件,所以我可能也需要安装它.

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

我在我的系统上安装了 gcc 的不同目录.然后我更改了 /usr/bingccg++ 的符号链接,以指向我的新 gcc 和 g++(在 gcc 内).现在我得到了与我的 pi 上相同的 sqlcli.h 错误.是时候获取 DB2 客户端了.

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.

嗯.我有 db2 客户端 9.1.2.根据 db2 binding.gyp 文件中的一些搜索,我需要 9.7.

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

我安装了IBM Data Server Runtime Client V9.7",但是/opt/IBM/db2/V9.7/include<中没有sqlcli.h/code> 文件夹!我在另一台机器上有一个 V9.1.3,它确实有一个包含文件夹.所以我安装了 "IBM Data Server Client 9.7"使用我的一篇旧博客文章来帮助我.现在我从 node-gyp 构建中收到一个错误,即未声明 strcmp.我敢打赌我需要设置一个 lib 包含或节点环境变量.

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.

推荐答案

您可以将字符串函数的包含文件(例如#include <cstring>)添加到src/connection.抄送.那应该启用字符串功能;也许您需要将 strcmp() 替换为 std::strcmp() 然后.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 Linux 平台上从 Node.js 连接到 DB2

基础教程推荐