简体   繁体   中英

How to connect to Pervasive SQL server in Ruby Application?

I am trying to connect to a Pervasive Sql Server which is running on Windows machine from my Ruby application which is on Ubuntu Machine. Can Someone please help me on same. Thanks in advance

Below is my configuration on linux machine

/etc/freetds/freetds.conf

[pserver]
  host = XXX.XXX.XX.XXX
  port = 1583
  tds version = 8.0

Under /etc/odbcinst.ini, I have saved the driver info like below

[freetds]
  Description=freetds Driver
  Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
  Trace=Yes
  TraceFile=/tmp/freetds.log
  ForceTrave=Yes
  UsageCount=10
  fileusage=1
  dontdlclose=1
  TDS_Version = 8.0

In /etc/odbc.ini, client and database details

[pclient]
    Description     = Pervasive SQL Server
    Driver          = freetds
    Trace           = Yes
    Servername      = pserver
    Port            = 1583
    Database        = "MyDatabasename"
    TDS_Version     = 8.0
 tsql -S pserver -U db_username -P db_password -d MyDatabasename 

above cmd gives error saying Error 20009 (severity 9): Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused" There was a problem connecting to the server

  iodbctest ["DSN=pclient;UID=db_username;PWD=db_password"] 
this results in
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0812.0326

(iodbctest:6672): Gtk-WARNING **: 20:40:38.693: cannot open display:

Not able to understand the above result and how to handle this. Please help

As far as I know, the only way to access Pervasive PSQL from Ruby would be through ODBC. You need to use the Pervasive Client ODBC driver. Don't use the FreeTDS driver. I've never heard of using the FreeTDS driver to connect to Pervasive PSQL. In fact, this question mentions that FreeTDS doesn't work to Pervasive PSQL. Pervasive PSQL and Microsoft SQL Server are not the same product and the client for one cannot connect to the server of the other.

The short answer would be to install the Pervasive PSQL client on the Ubuntu machine, create the ODBC Datasource name pointing to the database on the Windows machine and then use ODBC from within Ruby to access the data.
You'll want to be on at least Pervasive PSQL v11.30, preferably Actian PSQL v13 (current version as of December 2018). You'll need to download and install the client appropriate for the application. If the Ruby application is 32 bit, you need the 32 bit ODBC driver. If the application is 64 bit, you'll need the 64 bit driver. The 'bitness' of the OS is not as important. You need to use the same PSQL client version as server version. You cannot use the v13 client with a v11 server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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