简体   繁体   English

Ubuntu 12.04 LTS 64 + unixODBC 2.3.1 + Informix客户端dk 4.10 + node.js v0.10.20

[英]Ubuntu 12.04 LTS 64 + unixODBC 2.3.1 + Informix clientsdk 4.10 + node.js v0.10.20

I'd learn a lot readings yours questions and answers. 我会学到很多阅读您的问题和答案的信息。

But now i am lost 但是现在我迷路了

As you can see on title, i play with Ubuntu 12.04 LTS 64 + unixODBC 2.3.1 + Informix clientsdk 4.10 + node.js v0.10.20.... 如标题所示,我使用Ubuntu 12.04 LTS 64 + unixODBC 2.3.1 + Informix clientsdk 4.10 + node.js v0.10.20 ....

Every things is right until i try to connect in the node.js environment with unixODBC and the Informix Driver. 一切正常,直到我尝试使用unixODBC和Informix驱动程序在node.js环境中进行连接。

I have no problem with SQLServer. 我对SQLServer没问题。 So node is ok, unixODBC is ok and SQLServer Driver too. 这样节点就可以了,unixODBC也可以,SQLServer驱动程序也可以。 And the Informix Driver looks like is right too, but. 而且Informix驱动程序看起来也是正确的,但是。

I can $ isql -v MYDSN and query database. 我可以$ isql -v MYDSN和查询数据库。

But when the node App try to connect crash. 但是当节点App尝试连接时崩溃。

The DSN is realy easy and isql can play: DSN非常简单,isql可以播放:

/usr/local/etc/odbc.ini
[NIFX]
Driver=/opt/IBM/informix/lib/cli/iclit09b.so
Server=explotacion
LogonID=informix
pwd=enterpass
Database=data

and playing width isql looks well 并且播放宽度isql看起来不错

$ isql  NIFX
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>  SELECT COUNT(*) FROM PACIENTES   
+------------------+
|                  |
+------------------+
| 414396           |
+------------------+
SQLRowCount returns -1
1 rows fetched
SQL> 

My testifx.js for node looks 我的testifx.js节点外观

var Database = require("odbc").Database,
    db = new Database(),
    cn="DSN=NIFX"

db.open(cn, function (err) {
  if (err) return console.log(err);

  db.query('SELECT COUNT(*) FROM PACIENTES', [], function (err, data) {
    if (err) console.log(err);

    console.log(data);

    db.close(function () {
      console.log('done');
    });
  });
});

And the result... 结果是...

$ node testifx
{ error: '[node-odbc] SQL_ERROR',
  message: '[unixODBC][',
  state: '0' }
$ 

Can any one help me with this. 谁能帮我这个。

What's wrong width odbc.ini or maybe put some other parametrers in the connection string (I've tray all found out there in the google space) odbc.ini的宽度有什么问题,或者在连接字符串中放了一些其他参数(我已经在Google空间中找到了所有托盘)

Thanks really much. 非常感谢。


Thanks Michael Sorry for the long log. 感谢Michael Sorry的冗长日志。

I've done what you say. 我已经按照你说的做了。 First log trace to file settings the appropriate environment in odbcinst.ini 首先日志跟踪到文件设置odbcinst.ini中的适当环境

[ODBC]
TraceFile = /home/srlopez/Dev/unixODBC.log
Trace = Yes

Second, run isql -v NIFX , and play a single command SELECT COUNT(*) FROM FSIGBLO . 其次,运行isql -v NIFX ,并播放单个命令SELECT COUNT(*)FROM FSIGBLO I just direct the DSN by name. 我只是按名称指示DSN。

Done right and the trace is: 做对了,踪迹是:

[ODBC][7151][1380810414.400667][__handles.c][460]
        Exit:[SQL_SUCCESS]
            Environment = 0x63c750
[ODBC][7151][1380810414.400743][SQLAllocHandle.c][375]
        Entry:
            Handle Type = 2
            Input Handle = 0x63c750
[ODBC][7151][1380810414.400773][SQLAllocHandle.c][493]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x63d070
[ODBC][7151][1380810414.400803][SQLConnect.c][3700]
        Entry:
            Connection = 0x63d070
            Server Name = [NIFX][length = 4 (SQL_NTS)]
            User Name = [NULL]
            Authentication = [NULL]
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'

[ODBC][7151][1380810414.803879][SQLConnect.c][4273]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810414.810623][SQLGetFunctions.c][151]
        Entry:
            Connection = 0x63d070
            Id = SQLMoreResults
            Supported = 0x6061d8
[ODBC][7151][1380810414.810759][SQLGetFunctions.c][186]
        Exit:[SQL_SUCCESS]
            Supported = 0x6061d8 -> 1
[ODBC][7151][1380810428.644512][SQLAllocHandle.c][540]
        Entry:
            Handle Type = 3
            Input Handle = 0x63d070
[ODBC][7151][1380810428.644621][SQLAllocHandle.c][1081]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x6b7aa0
[ODBC][7151][1380810428.644661][SQLPrepare.c][196]
        Entry:
            Statement = 0x6b7aa0
            SQL = [SELECT COUNT(*) FROM FSIGBLO ][length = 29]
[ODBC][7151][1380810428.646046][SQLPrepare.c][371]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.646087][SQLExecute.c][187]
        Entry:
            Statement = 0x6b7aa0
[ODBC][7151][1380810428.646913][SQLExecute.c][348]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.646949][SQLNumResultCols.c][156]
        Entry:
            Statement = 0x6b7aa0
            Column Count = 0x7fffc7b20e8e
[ODBC][7151][1380810428.646984][SQLNumResultCols.c][248]
        Exit:[SQL_SUCCESS]
            Count = 0x7fffc7b20e8e -> 1
[ODBC][7151][1380810428.647030][SQLNumResultCols.c][156]
        Entry:
            Statement = 0x6b7aa0
            Column Count = 0x7fffc7b20bae
[ODBC][7151][1380810428.647057][SQLNumResultCols.c][248]
        Exit:[SQL_SUCCESS]
            Count = 0x7fffc7b20bae -> 1
[ODBC][7151][1380810428.647090][SQLColAttribute.c][293]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Field Identifier = SQL_DESC_DISPLAY_SIZE
            Character Attr = (nil)
            Buffer Length = 0
            String Length = (nil)
            Numeric Attribute = 0x7fffc7b20a08
[ODBC][7151][1380810428.647129][SQLColAttribute.c][664]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.647156][SQLColAttribute.c][293]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Field Identifier = SQL_DESC_LABEL
            Character Attr = 0x7fffc7b20a10
            Buffer Length = 301
            String Length = (nil)
            Numeric Attribute = (nil)
[ODBC][7151][1380810428.647192][SQLColAttribute.c][664]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.647218][SQLColAttribute.c][293]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Field Identifier = SQL_DESC_LABEL
            Character Attr = 0x7fffc7b20cf0
            Buffer Length = 301
            String Length = (nil)
            Numeric Attribute = (nil)
[ODBC][7151][1380810428.647244][SQLColAttribute.c][664]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.647295][SQLNumResultCols.c][156]
        Entry:
            Statement = 0x6b7aa0
            Column Count = 0x7fffc7b20bbe
[ODBC][7151][1380810428.647322][SQLNumResultCols.c][248]
        Exit:[SQL_SUCCESS]
            Count = 0x7fffc7b20bbe -> 1
[ODBC][7151][1380810428.647347][SQLFetch.c][162]
        Entry:
            Statement = 0x6b7aa0
[ODBC][7151][1380810428.648100][SQLFetch.c][348]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.648137][SQLColAttribute.c][293]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Field Identifier = SQL_DESC_DISPLAY_SIZE
            Character Attr = (nil)
            Buffer Length = 0
            String Length = (nil)
            Numeric Attribute = 0x7fffc7b20a28
[ODBC][7151][1380810428.648164][SQLColAttribute.c][664]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.648189][SQLColAttribute.c][293]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Field Identifier = SQL_DESC_LABEL
            Character Attr = 0x7fffc7b20a30
            Buffer Length = 301
            String Length = (nil)
            Numeric Attribute = (nil)
[ODBC][7151][1380810428.648218][SQLColAttribute.c][664]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810428.648254][SQLGetData.c][237]
        Entry:
            Statement = 0x6b7aa0
            Column Number = 1
            Target Type = 1 SQL_CHAR
            Buffer Length = 301
            Target Value = 0x7fffc7b20d00
            StrLen Or Ind = 0x7fffc7b20bb0
[ODBC][7151][1380810428.648358][SQLGetData.c][501]
        Exit:[SQL_SUCCESS]                
            Buffer = [2]                
            Strlen Or Ind = 0x7fffc7b20bb0 -> 1
[ODBC][7151][1380810428.648453][SQLFetch.c][162]
        Entry:
            Statement = 0x6b7aa0
[ODBC][7151][1380810428.648485][SQLFetch.c][348]
        Exit:[SQL_NO_DATA]
[ODBC][7151][1380810428.677380][SQLRowCount.c][173]
        Entry:
            Statement = 0x6b7aa0
            Row Count = 0x7fffc7b20e48
[ODBC][7151][1380810428.677455][SQLRowCount.c][244]
        Exit:[SQL_SUCCESS]
            Row Count = 0x7fffc7b20e48 -> -1
[ODBC][7151][1380810428.677539][SQLMoreResults.c][162]
        Entry:
            Statement = 0x6b7aa0
[ODBC][7151][1380810428.678583][SQLMoreResults.c][317]
        Exit:[SQL_NO_DATA]
[ODBC][7151][1380810428.678630][SQLFreeStmt.c][144]
        Entry:
            Statement = 0x6b7aa0
            Option = 1
[ODBC][7151][1380810428.678661][SQLFreeHandle.c][381]
        Entry:
            Handle Type = 3
            Input Handle = 0x6b7aa0
[ODBC][7151][1380810428.679476][SQLFreeHandle.c][491]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810430.715614][SQLDisconnect.c][208]
        Entry:
            Connection = 0x63d070
[ODBC][7151][1380810430.719032][SQLDisconnect.c][364]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810430.719070][SQLFreeHandle.c][284]
        Entry:
            Handle Type = 2
            Input Handle = 0x63d070
[ODBC][7151][1380810430.719093][SQLFreeHandle.c][333]
        Exit:[SQL_SUCCESS]
[ODBC][7151][1380810430.719116][SQLFreeHandle.c][219]
        Entry:
            Handle Type = 1
            Input Handle = 0x63c750

Then run node test.js, with this Connection string cn='NIFX' to pass the same information on odbc.ini to both environments isql and node. 然后运行带有该连接字符串cn ='NIFX'的节点test.js,将odbc.ini上的相同信息传递给环境isql和node。 and the trace is 踪迹是

[ODBC][7171][1380810558.770556][__handles.c][460]
        Exit:[SQL_SUCCESS]
            Environment = 0x1438f10
[ODBC][7171][1380810558.770647][SQLSetEnvAttr.c][189]
        Entry:
            Environment = 0x1438f10
            Attribute = SQL_ATTR_ODBC_VERSION
            Value = 0x3
            StrLen = -5
[ODBC][7171][1380810558.770677][SQLSetEnvAttr.c][363]
        Exit:[SQL_SUCCESS]
[ODBC][7171][1380810558.781819][SQLAllocHandle.c][375]
        Entry:
            Handle Type = 2
            Input Handle = 0x1438f10
[ODBC][7171][1380810558.782068][SQLAllocHandle.c][493]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x7fc6000008c0
[ODBC][7171][1380810558.782802][SQLSetConnectAttrW.c][332]
        Entry:
            Connection = 0x7fc6000008c0
            Attribute = SQL_ATTR_LOGIN_TIMEOUT
            Value = 0x7fc607ffee4c
            StrLen = 4
[ODBC][7171][1380810558.782922][SQLSetConnectAttrW.c][616]
        Exit:[SQL_SUCCESS]
[ODBC][7171][1380810558.782968][SQLDriverConnectW.c][290]
        Entry:
            Connection = 0x7fc6000008c0
            Window Hdl = (nil)
            Str In = [DSN=NIFX][length = 9]
            Str Out = (nil)
            Str Out Max = 0
            Str Out Ptr = (nil)
            Completion = 0
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'

**[ODBC][7171][1380810558.787449][SQLDriverConnectW.c][699]
        Exit:[SQL_ERROR]**
[ODBC][7171][1380810558.787689][SQLGetDiagFieldW.c][792]
        Entry:
            Connection = 0x7fc6000008c0
            Rec Number = 1
            Diag Ident = 2
            Diag Info Ptr = 0x7fffdc53aca8
            Buffer Length = -6
            String Len Ptr = 0x7fffdc53acae
[ODBC][7171][1380810558.787802][SQLGetDiagFieldW.c][812]
        Exit:[SQL_SUCCESS]
[ODBC][7171][1380810558.787839][SQLGetDiagRecW.c][508]
        Entry:
            Connection = 0x7fc6000008c0
            Rec Number = 1
            SQLState = 0x7fffdc53aeb0
            Native = 0x7fffdc53aca4
            Message Text = 0x7fffdc53acb0
            Buffer Length = 512
            Text Len Ptr = 0x7fffdc53acae
[ODBC][7171][1380810558.787873][SQLGetDiagRecW.c][550]
        Exit:[SQL_SUCCESS]
            SQLState = H
            Native = 0x7fffdc53aca4 -> -11060
            Message Text = [[unixODBC][]
[ODBC][7171][1380810558.788053][SQLGetDiagRecW.c][508]
        Entry:
            Connection = 0x7fc6000008c0
            Rec Number = 2
            SQLState = 0x7fffdc53aeb0
            Native = 0x7fffdc53aca4
            Message Text = 0x7fffdc53acb0
            Buffer Length = 512
            Text Len Ptr = 0x7fffdc53acae
[ODBC][7171][1380810558.788174][SQLGetDiagRecW.c][550]
        Exit:[SQL_SUCCESS]
            SQLState = 0
            Native = 0x7fffdc53aca4 -> -11005
            Message Text = [[unixODBC][]

And these are my conclusion. 这些是我的结论。 node playing with unixODBC call differents functions. 用unixODBC玩的节点调用了差函数。 isql call SQLConnect.c and node call SQLDriverConnectW.c , like this: isql调用SQLConnect.c节点调用SQLDriverConnectW.c ,如下所示:

NODE just functions calls until Connect NODE只会执行呼叫直到连接

[ODBC][7171][1380810558.770556][__handles.c][460]
[ODBC][7171][1380810558.770647][SQLSetEnvAttr.c][189]
[ODBC][7171][1380810558.770677][SQLSetEnvAttr.c][363]
[ODBC][7171][1380810558.781819][SQLAllocHandle.c][375]
[ODBC][7171][1380810558.782068][SQLAllocHandle.c][493]
[ODBC][7171][1380810558.782802][SQLSetConnectAttrW.c][332]
[ODBC][7171][1380810558.782922][SQLSetConnectAttrW.c][616]
[ODBC][7171][1380810558.782968][SQLDriverConnectW.c][290]
        Entry:
            Connection = 0x7fc6000008c0
            Window Hdl = (nil)
            Str In = [DSN=NIFX][length = 9]
            Str Out = (nil)
            Str Out Max = 0
            Str Out Ptr = (nil)
            Completion = 0
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'

[ODBC][7171][1380810558.787449][SQLDriverConnectW.c][699]
        Exit:[SQL_ERROR]

isql just functions calls until Connect isql只是函数调用直到连接

[ODBC][7151][1380810414.400667][__handles.c][460]
[ODBC][7151][1380810414.400743][SQLAllocHandle.c][375]
[ODBC][7151][1380810414.400773][SQLAllocHandle.c][493]
[ODBC][7151][1380810414.400803][SQLConnect.c][3700]
        Entry:
            Connection = 0x63d070
            Server Name = [NIFX][length = 4 (SQL_NTS)]
            User Name = [NULL]
            Authentication = [NULL]
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'

**[ODBC][7151][1380810414.803879][SQLConnect.c][4273]
        Exit:[SQL_SUCCESS]**

How to address this question? 如何解决这个问题? Thanks in advance again. 再次感谢。

Santi 桑蒂

You can enable ODBC call tracing. 您可以启用ODBC调用跟踪。 At first run isql to obtain log of valid calls. 首先,运行isql以获取有效调用的日志。 Then do the same for node.js . 然后对node.js执行相同的操作。 Comparing them should show you where is the problem. 比较它们应该可以告诉您问题出在哪里。

There is my question and answer on how to enable ODBC tracing for Informix on Linux : Tracing ODBC calls for Informix Client for Linux 关于如何在Linux上为Informix启用ODBC跟踪,我有一个问题和答案: 为Linux的Informix Client跟踪ODBC调用

EDIT: 编辑:

From logs it seems that node.js uses SQLDriverConnectW() which ends with error: -11005. 从日志看来, node.js使用SQLDriverConnectW()并以错误-11005结尾。 Informix show error describe this as "Invalid connection string attribute." Informix显示错误将其描述为“无效的连接字符串属性”。 .

You can use the same connect string as isql : 您可以使用与isql相同的连接字符串:

cn="NIFX"

If it do not work than maybe you should add user/password: 如果不起作用,则应该添加用户名/密码:

cn="Dsn=NIFX;Uid=myUsername;Pwd=myPassword;"

In Python I often use it in form: 在Python中,我经常以以下形式使用它:

dsn/user/password

You can also try to add to connect string more info just like it is shown on: http://www.connectionstrings.com/informix 您也可以尝试添加连接字符串更多信息,就像在http://www.connectionstrings.com/informix上显示的一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM