首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正在工作,但不工作

正在工作,但不工作
EN

Ask Ubuntu用户
提问于 2016-07-13 15:33:58
回答 1查看 1.1K关注 0票数 0

我对Linux不是很在行,但我能够勉强过关。我的最后一个目标是让RODBC在一个闪亮的应用程序中工作,连接到一个oracle11.1g数据库。我的第一步是在Ubuntu上设置oracle客户机。

Ubuntu版本详细信息:

代码语言:javascript
复制
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:    14.04
Codename:   trusty

我按照下列指示行事:

https://help.ubuntu.com/community/Oracle%20Instant%20Client

来安装客户端。我还包括odbc包。我能够很容易地获得sqlplus连接到数据库,但是显示中的RODBC仍然无法工作。当我试图在终端窗口中使用isql时,它失败了。为了克服这个问题,我安装了freeTDS。

代码语言:javascript
复制
sudo apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc

我已经配置了如下文件。

代码语言:javascript
复制
--- /etc/odbcinst.ini ---
[Oracle]
Description = Oracle ODBC Connection
Driver = /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1

--- /etc/odbc.ini ---
[STODS1]
Driver = Oracle
ServerName = STODS1
Port = 1521
Database = STODS1
TDS_Version = 7.1

--- /etc/freetds/freetds.conf ---
[global]
tds version = 7.1

[STODS1]
host = stods1.xxxx.xxxxxxx.com
port = 1521
tds version = 7.1

使用此配置,我从不同的命令获得以下响应

代码语言:javascript
复制
isql STODS1 USER PASSWORD -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

可以看出,isql工作得很好。

但是osql失败了。

代码语言:javascript
复制
sudo osql -S "STODS1" -U USER -P PASSWORD
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
trying /tmp/sql ... no
    trying /tmp/sql ... no
trying /etc ... OK
checking odbc.ini files
    reading /home/oper/.odbc.ini
[STODS1] not found in /home/oper/.odbc.ini
    reading /etc/odbc.ini
[STODS1] found in /etc/odbc.ini
found this section:
[STODS1]
    Driver = Oracle
    ServerName = STODS1
    Port = 1521
    Database = STODS1
    TDS_Version = 7.1
looking for driver for DSN [STODS1] in /etc/odbc.ini
found driver line: "    Driver = Oracle"
driver "Oracle" found for [STODS1] in odbc.ini
found driver named "Oracle"
"Oracle" is not an executable file
looking for entry named [Oracle] in /etc/odbcinst.ini
found driver line: "    Driver = /usr/lib/oracle/12.1/client64
/lib/libsqora.so.12.1"
found driver /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1 for   
[Oracle] in odbcinst.ini
/usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1 is an executable file
Using ODBC-Combined strategy
DSN [STODS1] has servername "STODS1" (from /etc/odbc.ini)
cannot read "/home/oper/.freetds.conf"
/etc/freetds/freetds.conf is a readable file
looking for [STODS1] in /etc/freetds/freetds.conf
found this section:
    [STODS1]
    host = stods1.xxxx.xxxxxx.com
    port = 1521
    tds version = 7.1

Configuration looks OK.  Connection details:

               DSN: STODS1                        
          odbc.ini: /etc/odbc.ini                 
            Driver: /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
   Server hostname: stods1.xxxx.xxxxxx.com       
           Address: 10.17.16.44                   

Attempting connection as ESG_REPORT ...
+ isql STODS1 ESG_REPORT ESG_REPORT1 -v
[08004][unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the 
connect identifier specified

[ISQL]ERROR: Could not SQLConnect
sed: can't read /tmp/osql.dump.25185: No such file or directory

我不明白osql为什么失败,isql的工作原理就像osql在最后几行中使用isql一样。

tsql也失败了,从查看网络和手册来看,这似乎是由于TDS版本,但是我已经尝试了我在配置文件中知道的所有TDS版本,并强迫它使用TDSVER。

代码语言:javascript
复制
tsql -S STODS1 -U USER -P PASWORD
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20017 (severity 9):
    Unexpected EOF from the server
    OS error 115, "Operation now in progress"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

我想我已经包括了大部分的信息,但是如果你还有什么需要的话,请告诉我。我已经在这工作了5天了,所以有点厌倦了。任何帮助都会很好。

谢谢

EN

回答 1

Ask Ubuntu用户

发布于 2016-10-05 11:30:36

我不明白你为什么要使用freetds.conf。它通常用于访问Sybase和Microsoft数据库(cfr,它们的主页)。我将抑制(或至少重命名) freetds.conf文件,并将所有内容放在odbc.ini文件中(我让它让您决定用户is /密码是否更好地编码在ini文件或其他地方):

代码语言:javascript
复制
--- /etc/odbc.ini ---
[STODS1]
Driver = Oracle
Server = stods1.xxxx.xxxxxxx.com
Port = 1521
Database = STODS1
USER = youroracleusername
PASSWORD = youroracleuserpassword
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/798202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档