我对Linux不是很在行,但我能够勉强过关。我的最后一个目标是让RODBC在一个闪亮的应用程序中工作,连接到一个oracle11.1g数据库。我的第一步是在Ubuntu上设置oracle客户机。
Ubuntu版本详细信息:
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。
sudo apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc我已经配置了如下文件。
--- /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使用此配置,我从不同的命令获得以下响应
isql STODS1 USER PASSWORD -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> 可以看出,isql工作得很好。
但是osql失败了。
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。
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天了,所以有点厌倦了。任何帮助都会很好。
谢谢
发布于 2016-10-05 11:30:36
我不明白你为什么要使用freetds.conf。它通常用于访问Sybase和Microsoft数据库(cfr,它们的主页)。我将抑制(或至少重命名) freetds.conf文件,并将所有内容放在odbc.ini文件中(我让它让您决定用户is /密码是否更好地编码在ini文件或其他地方):
--- /etc/odbc.ini ---
[STODS1]
Driver = Oracle
Server = stods1.xxxx.xxxxxxx.com
Port = 1521
Database = STODS1
USER = youroracleusername
PASSWORD = youroracleuserpasswordhttps://askubuntu.com/questions/798202
复制相似问题