2007年12月20日 星期四

freebsd下用unixodbc連sqlserver

FreeBSD環境下設定odbc



  • 安裝unixODBC
                cd  /usr/ports/database/unixODBC; make install clean


  • 安裝MySQL ODBC Driver
                cd  /usr/ports/database/mysql-connector-odbc; make install clean

  • 安裝MS SQLServer ODBC Driver

                cd  /usr/ports/database/freetds-msdblib; make install clean


 



  • /usr/local/etc/odbcinst.ini 指定安裝的odbc library位置,例如

==================================================
[MySQL]
Description             = ODBC Driver for MySQL
Driver          = /usr/local/lib/libmyodbc3.so
Setup           = /usr/local/lib/libodbcmyS.so
FileUsage               = 1
CPTimeout               =
CPReuse         =

[FreeTDS]
Description             = ODBC Driver for MS SQL server /Sybase v0.63
Driver          = /usr/local/lib/libtdsodbc.so
Setup           = /usr/local/lib/libtdsS.so
UsageCount              = 2

=======================================


 



  •  /usr/local/etc/odbc.ini 整定DSN (Data Source Name),例如

================================================


[MySQL-test]
Description     = MySQL database test
Driver          = MySQL
Server          = localhost
Database        = databasename
Port            = 3306
Socket          =
Option          =
Stmt            =

[MS-SQLServer-test]
Description     = MS SQLServer(OR Sybase) database test
Driver          = FreeTDS
Server          = IP Address
Port            = PortNumber(1433)
Database        = databasename
Trace           = No
========================================================

 


測試程式:isql


***


NOTE:


亦可以由/usr/ports/databases/freetds編譯**,但是注意TDS Version內定為5.0,版本適用範圍請參閱下列網址 http://www.freetds.org/userguide/choosingtdsprotocol.htm


 測試以8.0連接SQL EXPRESS( SQL Server 2005),能順利連接但無法下SQL指令,改用7.0則正常運作。


 **


make   TDS_VER=7.0 -DWITH_MSDBLIB install clean 


沒有留言:

張貼留言