Nsodbc

From AOLserver Wiki
Jump to: navigation, search

nsodbc is an internal DB driver for AOLserver that enables you to connect to databases that have an ODBC driver using an ODBC manager and the nsodbc module.

Dossy: I have gotten AOLserver 4.x on Debian Linux (sid) to work with nsodbc connecting to MySQL using unixODBC as the ODBC manager and MyODBC as the ODBC driver. Specific versions of interest for folks looking to do similar:

  • Linux ecwav 2.4.20 #1 Sat May 24 08:47:33 EDT 2003 i686 GNU/Linux [1]
  • AOLserver 4.1.0 (CVS HEAD as of 14mar2004) [2]
  • nsodbc (CVS HEAD as of 14mar2004) [3]
  • unixODBC 2.2.8 [4]
  • MyODBC 3.51.06 [5]
  • MySQL 3.23.49 [6]

The nsodbc module requires minor changes (which should be committed to CVS soon) but until then, the patch is available here:


Specifically, here's how I built unixODBC and MyODBC and nsodbc:

unixODBC

 $ ./configure --prefix=/usr

MyODBC

 $ ./configure --prefix=/usr --enable-thread-safe --with-unixODBC=/usr --with-debug \
     --with-mysql-libs=/usr/lib --with-mysql-includes=/usr/include/mysql \
     --with-odbc-ini=/usr/etc/odbc.ini

nsodbc

 $ make ODBC=/usr/lib

Here are what my configuration files look like:

/usr/etc/odbcinst.ini

  [ODBC]
  Trace           = off
  TraceFile       = /tmp/sql.log
  
  [myodbc]
  Description     = MySQL ODBC 2.50 Driver DSN
  Driver          = /usr/lib/libmyodbc.so
  Setup           = /usr/lib/libodbcmyS.so
  FileUsage       = 1
  
  [myodbc3]
  Description     = MySQL ODBC 3.51 Driver
  Driver          = /usr/lib/libmyodbc3.so
  Setup           = /usr/lib/libodbcmyS.so
  FileUsage       = 1

/usr/etc/odbc.ini

  [ODBC Data Sources]
  MySQL-test=MySQL test database
  
  [MySQL-test]
  Description = MySQL test database
  Trace       = off
  TraceFile   = /tmp/sql.log
  Driver      = myodbc3
  Server      = 127.0.0.1
  Port        = 3306
  User        = dossy
  Password    = 
  Database    = dossy
  Option      = 3
  Socket      = 

[ N.B.: I really DID leave the Password field blank in the odbc.ini. Also, if you specify Server as "localhost" and Socket as empty, it still tries to connect using the Unix socket based off the default in libmysqlclient instead of via TCP. The only way I could get it to do TCP was to specify Server as an IP address and not a hostname. I probably spent two hours trying to figure out why it refused to connect via TCP until I discovered this. ]

init.tcl (only the relevant excerpt here)

  ns_section "ns/db/drivers"
  ns_param odbc         nsodbc.so

  ns_section "ns/db/pools"
  ns_param dossyodbcdb    "Dossy's MySQL-test ODBC pool"

  ns_section "ns/db/pool/dossyodbcdb"
  ns_param driver       odbc
  ns_param connections  1
  ns_param user         dossy
  ns_param password     $password
  ns_param datasource   MySQL-test
  ns_param logsqlerrors on
  ns_param verbose      on