简体   繁体   English

如何在Ruby应用程序中连接到Pervasive SQL Server?

[英]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. 我正在尝试从Ubuntu计算机上的Ruby应用程序连接到Windows计算机上运行的Pervasive Sql Server。 Can Someone please help me on same. 有人可以帮我吗? Thanks in advance 提前致谢

Below is my configuration on linux machine 以下是我在linux机器上的配置

/etc/freetds/freetds.conf /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 在/etc/odbcinst.ini下,我保存了如下驱动程序信息

[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 在/etc/odbc.ini中,客户端和数据库详细信息

[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 上面的cmd给出错误,提示错误20009(严重性9):无法连接:Adaptive Server不可用或不存在OS错误111,“连接被拒绝”连接到服务器时出现问题

  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. 据我所知,从Ruby访问Pervasive PSQL的唯一方法是通过ODBC。 You need to use the Pervasive Client ODBC driver. 您需要使用Pervasive Client ODBC驱动程序。 Don't use the FreeTDS driver. 不要使用FreeTDS驱动程序。 I've never heard of using the FreeTDS driver to connect to Pervasive PSQL. 我从未听说过使用FreeTDS驱动程序连接到Pervasive PSQL。 In fact, this question mentions that FreeTDS doesn't work to Pervasive PSQL. 实际上,这个问题提到FreeTDS不适用于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. 普及型PSQL和Microsoft SQL Server不是同一产品,其中一个的客户端无法连接到另一个的服务器。

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. 简短的答案是在Ubuntu计算机上安装Pervasive PSQL客户端,在Windows计算机上创建指向数据库的ODBC数据源名称,然后在Ruby中使用ODBC来访问数据。
You'll want to be on at least Pervasive PSQL v11.30, preferably Actian PSQL v13 (current version as of December 2018). 您需要至少使用Pervasive PSQL v11.30,最好是Actian PSQL v13(截至2018年12月的当前版本)。 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. 如果Ruby应用程序是32位的,则需要32位的ODBC驱动程序。 If the application is 64 bit, you'll need the 64 bit driver. 如果应用程序是64位,则需要64位驱动程序。 The 'bitness' of the OS is not as important. 操作系统的“位”并不那么重要。 You need to use the same PSQL client version as server version. 您需要使用与服务器版本相同的PSQL客户端版本。 You cannot use the v13 client with a v11 server. 您不能将v13客户端与v11服务器一起使用。

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

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