sql-server - 使用 unixODBC 的 isql 访问 sql server
问题描述
我正在尝试在客户端服务器上使用 isql 在 sql server (source) 上运行查询。在客户端服务器上的 rhel6 到 rhel7 升级之前一切正常。我能够连接到 sql server 只是不运行任何查询。我确认所有驱动程序都在那里,并且没有更改任何 odbc 文件。我可以在不同的环境中重现它并且效果很好。
$ export ODBCINI=/etc/alternatives/dmexpress/etc/odbc.ini
$ export ODBCSYSINI=/etc/alternatives/dmexpress/etc
$ export LD_LIBRARY_PATH=/etc/alternatives/dmexpress/ThirdParty/DataDirect/lib:/etc/alternatives/dmexpress/lib/:/opt/cloudera/impalaodbc/lib/64:/opt/cloudera/hiveodbc/lib/64
$ export PATH=/etc/alternatives/dmexpress/bin:/opt/cloudera/parcels/CDH/jars:$PATH
$ isql -v Hadoop_Monitoring_Dev $user $password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> SELECT name FROM master.sys.databases
[60][DMExpress][ODBC 20101 driver]6091
[ISQL]ERROR: Could not SQLExecute
$ cat /etc/alternatives/dmexpress/etc/odbc.ini
[ODBC]
InstallDir=/etc/alternatives/dmexpress/ThirdParty/DataDirect/lib
Trace = Yes
TraceFile = /tmp/odbc.trace
[Hadoop_Monitoring_Dev]
Driver=/etc/alternatives/dmexpress/ThirdParty/DataDirect/lib/_Ssqls27.so
Description=DataDirect SQL Server Wire Protocol
AlwaysReportTriggerResults=0
AnsiNPW=1
ApplicationUsingThreads=1
AuthenticationMethod=1
BulkBinaryThreshold=32
BulkCharacterThreshold=-1
BulkLoadBatchSize=1024
BulkLoadOptions=0
ConnectionReset=0
ConnectionRetryCount=0
ConnectionRetryDelay=3
ConvWToUtf=1
Database=Hadoop_Monitoring_d10
DefaultLongDataBuffLen=1024
EnableBulkLoad=1
EnableQuotedIdentifiers=1
EncryptionMethod=0
FailoverGranularity=0
FailoverMode=0
FailoverPreconnect=0
FetchTSWTZasTimestamp=0
FetchTWFSasTime=1
GSSClient=native
HostName=dbhadoopmonitoringd10
LoadBalanceTimeout=0
LoadBalancing=0
LoginTimeout=15
LogonID=
MaxPoolSize=100
MinPoolSize=0
PacketSize=-1
Password=
Pooling=0
PortNumber=1460
QueryTimeout=0
ReportCodePageConversionErrors=0
SnapshotSerializable=0
ValidateServerCertificate=1
XMLDescribeType=-10
QEWSD=2457584
$ cat /etc/alternatives/dmexpress/etc/odbcinst.ini
[ODBC]
Trace = Yes
TraceFile = /tmp/odbcinst.trace
$ cat /etc/alternatives/dmexpress/etc/odbcinst.ini
# SQL Server driver.
[DataDirect SQL Server Wire Protocol]
Driver=/etc/alternatives/dmexpress/ThirdParty/DataDirect/lib/_Ssqls27.so
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=3.52
FileUsage=0
HelpRootDirectory=/help
Setup=/etc/alternatives/dmexpress/ThirdParty/DataDirect/lib/_Ssqls27.so
SQLLevel=0
DMXODBCDRIVERMANAGER=NO
我确实得到了一个从 odbcinst.ini 调用的跟踪文件,但它并没有告诉我太多信息
$ cat odbcinst.trace
[ODBC][552119][1628599776.361874][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x1dae750
[ODBC][552119][1628599776.362006][SQLAllocHandle.c][375]
Entry:
Handle Type = 2
Input Handle = 0x1dae750
[ODBC][552119][1628599776.362088][SQLAllocHandle.c][493]
Exit:[SQL_SUCCESS]
Output Handle = 0x1daf050
[ODBC][552119][1628599776.362155][SQLConnect.c][3700]
Entry:
Connection = 0x1daf050
Server Name = [Hadoop_Monitoring_Dev][length = 21 (SQL_NTS)]
User Name = [a00946r2][length = 8 (SQL_NTS)]
Authentication = [********][length = 8 (SQL_NTS)]
UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'
DIAG [2] [DMExpress][ODBC 20101 driver][Microsoft SQL Server]Changed database context to 'Hadoop_Monitoring_d10'.
DIAG [2] [DMExpress][ODBC 20101 driver][Microsoft SQL Server]Changed language setting to us_english.
[ODBC][552119][1628599776.579031][SQLConnect.c][4273]
Exit:[SQL_SUCCESS_WITH_INFO]
[ODBC][552119][1628599776.579131][SQLGetFunctions.c][151]
Entry:
Connection = 0x1daf050
Id = SQLMoreResults
Supported = 0x607200
[ODBC][552119][1628599776.579187][SQLGetFunctions.c][186]
Exit:[SQL_SUCCESS]
Supported = 0x607200 -> 1
[ODBC][552119][1628599783.373310][SQLAllocHandle.c][540]
Entry:
Handle Type = 3
Input Handle = 0x1daf050
[ODBC][552119][1628599783.373510][SQLAllocHandle.c][1081]
Exit:[SQL_SUCCESS]
Output Handle = 0x1e4c8c0
[ODBC][552119][1628599783.373587][SQLPrepare.c][196]
Entry:
Statement = 0x1e4c8c0
SQL = [select count(*) from [Hadoop_Monitoring_d10].[dbo].[SCPT_EXEC]]
[length = 62]
[ODBC][552119][1628599783.374670][SQLPrepare.c][371]
Exit:[SQL_ERROR]
DIAG [60] [DMExpress][ODBC 20101 driver]6091
[ODBC][552119][1628599783.374814][SQLError.c][352]
Entry:
Statement = 0x1e4c8c0
SQLState = 0x7ffd0e17a2c0
Native = 0x7ffd0e17a2bc
Message Text = 0x7ffd0e17a2d0
Buffer Length = 500
Text Len Ptr = 0x7ffd0e17a2ba
[ODBC][552119][1628599783.374874][SQLError.c][389]
Exit:[SQL_SUCCESS]
SQLState = 60
Native = 0x7ffd0e17a2bc -> 6091
Message Text = [[DMExpress][ODBC 20101 driver]6091]
[ODBC][552119][1628599783.374941][SQLError.c][352]
Entry:
Statement = 0x1e4c8c0
SQLState = 0x7ffd0e17a2c0
Native = 0x7ffd0e17a2bc
Message Text = 0x7ffd0e17a2d0
Buffer Length = 500
Text Len Ptr = 0x7ffd0e17a2ba
[ODBC][552119][1628599783.374992][SQLError.c][389]
Exit:[SQL_NO_DATA]
[ODBC][552119][1628599783.375042][SQLError.c][434]
Entry:
Connection = 0x1daf050
SQLState = 0x7ffd0e17a2c0
Native = 0x7ffd0e17a2bc
Message Text = 0x7ffd0e17a2d0
Buffer Length = 500
Text Len Ptr = 0x7ffd0e17a2ba
[ODBC][552119][1628599783.375105][SQLError.c][471]
Exit:[SQL_NO_DATA]
[ODBC][552119][1628599783.375157][SQLError.c][514]
Entry:
Environment = 0x1dae750
SQLState = 0x7ffd0e17a2c0
Native = 0x7ffd0e17a2bc
Message Text = 0x7ffd0e17a2d0
Buffer Length = 500
Text Len Ptr = 0x7ffd0e17a2ba
[ODBC][552119][1628599783.375205][SQLError.c][551]
Exit:[SQL_NO_DATA]
[ODBC][552119][1628599783.375276][SQLFreeStmt.c][144]
Entry:
Statement = 0x1e4c8c0
Option = 1
[ODBC][552119][1628599783.375331][SQLFreeHandle.c][381]
Entry:
Handle Type = 3
Input Handle = 0x1e4c8c0
[ODBC][552119][1628599783.375415][SQLFreeHandle.c][491]
Exit:[SQL_SUCCESS]
解决方案
这是许可问题。我必须使 odbc.ini 可写,以便它可以写 qewsd https://www.ibm.com/support/pages/what-does-qewsd-mean-odbcini-file
推荐阅读
- r - 使用 R (rvest) 抓取表格
- python - 如何根据索引数量格式化列表
- xml - xslt apply-template 如何处理相同的子树匹配?
- javascript - 如何克服错误:未检查的 runtime.lastError:无法建立连接。接收端不存在
- python - 卡在 pytube
- reactjs - 使轮播在高度上响应以填充左侧空间
- android-gradle-plugin - 使用 Android Gradle Plugin 7+ 发布 Android 库的 SNAPSHOT 版本
- python - 如何解决 NameError: name Country is not defined with seaborn.barplot
- javascript - 如何用全局变量替换隐藏输入以保存数据
- c++ - 为什么此代码在交换值后输出垃圾值?