×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

请教那位有unixodbc的经验,我遇到了一个问题.redhat9安装了freetds和unixodbc,访问网内一台MS SQLserver2000数据.用unixodbc的测试程序isql已经可以连通并访问目标数据库,但是使用API做同样的事就失败.

本文发表在 rolia.net 枫下论坛测试程序isql用法如下:

[root@hippo9 fortest]#isql –v FIAT userid passwd
[root@hippo9 fortest]#isql –v FIAT userid passwd
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from hl_daemon
SQL>
[root@hippo9 fortest]#
[root@hippo9 fortest]#

isql测试成功说明配置及网络等都正常.但是执行一个使用unixodbc API的程序就只输出:

[root@hippo9 fortest]# ./odbc
Error SQLConnect -1
[unixODBC][Driver Manager]Data source name not found, and no default driver specified (0)
[root@hippo9 fortest]#

程序源码来自于:
http://www-128.ibm.com/developerworks/cn/linux/database/odbc/index.html

我的配置文件如下:
[root@hippo9 etc]# cat /usr/local/etc/odbcinst.ini
[TDS]
Description = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsS.so.1
UsageCount = 1

[root@hippo9 etc]# cat /usr/local/etc/odbc.ini
[FIAT]
Driver = TDS
Description = ODBC connection via FreeTDS
Trace = Yes
TraceFile = /tmp/sql.log
ServerName = MYFIAT
Database = hiplink
Port = 1433

[root@hippo9 etc]# cat /usr/local/etc/freetds.conf

[JDBC]
host = 192.138.151.39
port = 4444
tds version = 5.0
[JDBC_42]
host = 192.138.151.39
port = 4444
tds version = 4.2
[mypool]
host = 127.0.0.1
port = 5000
tds version = 4.2
[MYFIAT]
host = 192.168.50.131
port = 1433
tds version = 8.0更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / 请教那位有unixodbc的经验,我遇到了一个问题.redhat9安装了freetds和unixodbc,访问网内一台MS SQLserver2000数据.用unixodbc的测试程序isql已经可以连通并访问目标数据库,但是使用API做同样的事就失败.
    本文发表在 rolia.net 枫下论坛测试程序isql用法如下:

    [root@hippo9 fortest]#isql –v FIAT userid passwd
    [root@hippo9 fortest]#isql –v FIAT userid passwd
    +---------------------------------------+
    | Connected! |
    | |
    | sql-statement |
    | help [tablename] |
    | quit |
    | |
    +---------------------------------------+
    SQL> select * from hl_daemon
    SQL>
    [root@hippo9 fortest]#
    [root@hippo9 fortest]#

    isql测试成功说明配置及网络等都正常.但是执行一个使用unixodbc API的程序就只输出:

    [root@hippo9 fortest]# ./odbc
    Error SQLConnect -1
    [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0)
    [root@hippo9 fortest]#

    程序源码来自于:
    http://www-128.ibm.com/developerworks/cn/linux/database/odbc/index.html

    我的配置文件如下:
    [root@hippo9 etc]# cat /usr/local/etc/odbcinst.ini
    [TDS]
    Description = FreeTDS
    Driver = /usr/local/lib/libtdsodbc.so
    Setup = /usr/local/lib/libtdsS.so.1
    UsageCount = 1

    [root@hippo9 etc]# cat /usr/local/etc/odbc.ini
    [FIAT]
    Driver = TDS
    Description = ODBC connection via FreeTDS
    Trace = Yes
    TraceFile = /tmp/sql.log
    ServerName = MYFIAT
    Database = hiplink
    Port = 1433

    [root@hippo9 etc]# cat /usr/local/etc/freetds.conf

    [JDBC]
    host = 192.138.151.39
    port = 4444
    tds version = 5.0
    [JDBC_42]
    host = 192.138.151.39
    port = 4444
    tds version = 4.2
    [mypool]
    host = 127.0.0.1
    port = 5000
    tds version = 4.2
    [MYFIAT]
    host = 192.168.50.131
    port = 1433
    tds version = 8.0更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 拷贝/usr/local/etc/odbc.ini 到$HOME/.odbc.ini后SQLDataSources()已经可以成功取回DSN的信息了,可SQLConnect还是失败.奇怪!
      [root@hippo9 fortest]# ./odbc
      Server=(FIAT) Beschreibung=(TDS)
      Error SQLConnect -1
      [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0)
      [root@hippo9 fortest]#
      • 已经解决.cp /usr/local/etc/odbcinst.int /usr/local/unixODBC/etc/odbcinst.ini即可.谢谢关注.