Isql error could not sqlconnect

Ultimate goal: connect my Xubuntu 16.04 machine to a remote MS SQL Server 2017 database using pyodbc. Intermediate goal: get isql to work; tsql works, but not isql. I tried mirroring the setting...

Ultimate goal: connect my Xubuntu 16.04 machine to a remote MS SQL Server 2017 database using pyodbc.

Intermediate goal: get isql to work; tsql works, but not isql.

I tried mirroring the settings on my Mac — see this question for what worked. Unfortunately, no joy. I have looked through many SO questions, such as:
One, Two, and Three,
and tried their approaches, none of which work. I’m confident that the Linux machine has the right ports open, because tsql works from my Xubuntu 16.04 machine. Unfortunately, I cannot get isql to work. I get the dreaded

[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect

errors. Also unfortunately, much of the documentation I’ve seen seems woefully out-of-date and contradictory. For example:

  1. In the odbc.ini file, should it be Server = stuff, 1433 or Server = stuff or ServerName = stuff with a separate port = line, or should I go with instance? There are too many options, and not enough documentation to figure this out.
  2. What exactly should go in the odbcinst.ini file? I don’t have a libtdsS.so file in /usr/lib/x86_64-linux-gnu/odbc directory. Should I leave out the Setup line?
  3. What exactly should go in the freetds.conf file? Should I use the actual IP address?
  4. If I want to force FreeTDS to use a particular protocol version, how do I do that? Changing freetds.conf doesn’t appear to affect the results of tsql -C. Or do I just need to log out and back in?
  5. Taking a step back: is there a better approach to the whole darn thing? I’m not interested in pymssql, as it appears to be abandonware at this point, in favor of pyodbc.
  6. I note that the tsql -LH stuff command produces no output. Is that command deprecated? Or how could I get the right settings from any command?
  7. Is there up-to-date, clear documentation available anywhere? Or an up-to-date, clear installation and usage guide anywhere, with trouble-shooting steps for the more common problems?

Many thanks for your time!

[EDIT] Here are the contents of a tracelog after enabling:

[ODBC][34479][1567549751.158470][__handles.c][460]
        Exit:[SQL_SUCCESS]
            Environment = 0x1913750
[ODBC][34479][1567549751.158517][SQLAllocHandle.c][377]
        Entry:
            Handle Type = 2
            Input Handle = 0x1913750
[ODBC][34479][1567549751.158532][SQLAllocHandle.c][493]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x1914060
[ODBC][34479][1567549751.158551][SQLConnect.c][3721]
        Entry:
            Connection = 0x1914060
            Server Name = [ROEFDN806Q][length = 10 (SQL_NTS)]
            User Name = [mfadm210028][length = 12 (SQL_NTS)]
            Authentication = [********][length = 8 (SQL_NTS)]
[ODBC][34479][1567549751.158987][SQLConnect.c][3929]Error: IM002
[ODBC][34479][1567549751.159017][SQLError.c][424]
        Entry:
            Connection = 0x1914060
            SQLState = 0x7ffd099daf10
            Native = 0x7ffd099daf0c
            Message Text = 0x7ffd099daf20
            Buffer Length = 500
            Text Len Ptr = 0x7ffd099daf0a
[ODBC][34479][1567549751.159034][SQLError.c][474]
        Exit:[SQL_SUCCESS]
            SQLState = IM002
            Native = 0x7ffd099daf0c -> 0
            Message Text = [[unixODBC][Driver Manager]Data source name not found and no default driver specified]
[ODBC][34479][1567549751.159066][SQLError.c][424]
        Entry:
            Connection = 0x1914060
            SQLState = 0x7ffd099daf10
            Native = 0x7ffd099daf0c
            Message Text = 0x7ffd099daf20
            Buffer Length = 500
            Text Len Ptr = 0x7ffd099daf0a
[ODBC][34479][1567549751.159079][SQLError.c][474]
        Exit:[SQL_NO_DATA]
[ODBC][34479][1567549751.159089][SQLError.c][424]
        Entry:
            Environment = 0x1913750
            SQLState = 0x7ffd099daf10
            Native = 0x7ffd099daf0c
            Message Text = 0x7ffd099daf20
            Buffer Length = 500
            Text Len Ptr = 0x7ffd099daf0a
[ODBC][34479][1567549751.159099][SQLError.c][474]
        Exit:[SQL_NO_DATA]
[ODBC][34479][1567549751.159130][SQLFreeHandle.c][290]
        Entry:
            Handle Type = 2
            Input Handle = 0x1914060
[ODBC][34479][1567549751.159144][SQLFreeHandle.c][339]
        Exit:[SQL_SUCCESS]
[ODBC][34479][1567549751.159156][SQLFreeHandle.c][220]
        Entry:
            Handle Type = 1
            Input Handle = 0x1913750

Here is my current odbc.ini file:

[ROEFDN806Q]
Description = "EOAM_RA Server"
Driver = FreeTDS
ServerName = ROEFDN806Q
Server = 10.146.186.7
Port = 1433
Database = EOAM_RA
UsageCount = 1
TDS_Version = 7.3

And here’s my odbcinst.ini file:

[FreeTDS]
Description = "FreeTDS ODBC Driver"
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

[ODBC]
Trace = yes
TraceFile = /tmp/odbctrace.txt

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Comments

@GoogleCodeExporter

What steps will reproduce the problem?
1. test tsql [works]
2. test isql [no luck]
3. test iusql [no luck]

What is the expected output? What do you see instead?
EXPECTED
$isql -v ODBCNAME USERNAME PASSWORD
+---------------------------------------+
| Connected!    

but get:

[ISQL]ERROR: Could not SQLConnect
and 
[ISQL]ERROR: Could not SQLDriverConnect


What version of the product are you using? On what operating system?
unixODBC 2.2.14
Ubuntu12.04
MSSQL2008

Please provide any additional information below.

/odbc.log
[ODBC][14658][1375140244.455899][SQLConnect.c][3616]
                Entry:
                        Connection = 0x147c082
                        Server Name = (SQL_NTS)]
                        User Name =  (SQL_NTS)]
                        Authentication = [PW](SQL_NTS)]
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

                DIAG [42000] [FreeTDS][SQL Server]Login failed for user ''.

                DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to data source

Original issue reported on code.google.com by mseme...@gmail.com on 29 Jul 2013 at 11:42

@GoogleCodeExporter

Pls help...
$ isql -v ocs_cfg_db
[08004][unixODBC][ODBC Firebird Driver]File Database is not found
[ISQL]ERROR: Could not SQLConnect
$ odbcinst -q -s
[ocs_cfg_db]
$ odbcinst -q -d
[Firebird]
$ odbcinst -j
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/danateq/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

 odbc.ini 
[ocs_cfg_db]
Description     = Firebird
Driver          = Firebird
Dbname          = host/port:ocs_cfg_db
User            = sysdba
Password        = masterkey
Role            =
CharacterSet    =
ReadOnly        = No
NoWait          = No



 odbcinst.ini 
[Firebird]
Description=InterBase/Firebird ODBC Driver
Driver=/usr/lib64/libOdbcFb.so.2.1.0
Setup=/usr/lib64/libOdbcFb.so.2.1.0
FileUsage=1
CPTimeout=
CPReuse=
UsageCount=10



Original comment by wmsi...@gmail.com on 25 Sep 2013 at 6:31

@GoogleCodeExporter

This took me almost a week to figure out I'll see if I can help.

/etc/freetds/freetds.conf

# Define a connection to the Microsoft SQL Server
[mssql]
        host = XXXXXXXXXXXX - This is your server name.
        port = 1433
        tds version = 8.0

/etc/odbc.ini

# Define a connection to a Microsoft SQL server
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will 
connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description             = MSSQL Server
Driver                  = freetds
Database                = dbname #This is your Database name in MSSQL Server
Server                  = XXXXXXXXXXXX #This is your server name again
Port                    = 1433
TDS_Version             = 8.0

/etc/odbcinst.ini

# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS SQL database access with Free TDS
Driver          = /usr/lib/odbc/libtdsodbc.so
Setup           = /usr/lib/odbc/libtdsS.so
UsageCount      = 1

Make sure you're in the right location here.

Big thing that stands out is what's that Firebird driver?  If you're using 
MSSQL just use unixODBC and freeTDS newest versions for both will suffice.

Original comment by whoisea...@gmail.com on 11 Nov 2013 at 4:38

@GoogleCodeExporter

Wonderful help.. my paths were mostly different, but finding the locations and 
pointing to them worked fine. Thanks for your week of work!

Original comment by Henry.Co...@gmail.com on 30 Jun 2014 at 7:24

1 participant

@GoogleCodeExporter

My connection from Oracle 12c to PostgreSQL is returning the following:

select * from «test»@PG_LINK

                     *

ERROR at line 1:

ORA-28500: connection from ORACLE to a non-Oracle system returned this message:

[unixODBC]connction string lacks some options {08001,NativeErr = 202}

ORA-02063: preceding 2 lines from PG_LINK

Here is my setup.  Anyone have a time to take a look?

.odbc.ini

[ODBC Data Sources]

  PG_LINK=PostgreSQL

[PG_LINK]

Debug=255

  CommLog=1

  ReadOnly=no

  Driver=/usr/pgsql-9.4/lib/psqlodbcw.so

  Servername=<remove IP address>

  FetchBufferSize=99

  Username=csm_test

  Password=<removed>

  Port=5432

  Database=postgres

  TRACE=Yes

  TraceFile=/tmp/sql.log

  Protocol=7.4

  sslmode=disable

[Default]

  Driver=/usr/lib64/liboplodbcS.so.1

initPG_LINK.ora

HS_FDS_CONNECT_INFO = PG_LINK

HS_FDS_TRACE_LEVEL = 255

HS_FDS_SHAREABLE_NAME=/ora/dba/work/unixODBC/lib/libodbc.so

HS_LANGUAGE=american_america.we8iso8859p1

HS_NLS_NCHAR=UCS2

set ODBCINI=/u01/app/oracle/.odbc.ini

Generated trace file: PG_LINK_agt_13870.trc

Oracle Corporation — TUESDAY   OCT 20 2015 15:04:11.308

Heterogeneous Agent Release

  1. 12.1.0.2.0

Oracle Corporation — TUESDAY   OCT 20 2015 15:04:11.307

    Version 12.1.0.2.0

Entered hgogprd

HOSGIP for «HS_FDS_TRACE_LEVEL» returned «255»

Entered hgosdip

setting HS_OPEN_CURSORS to default of 50

setting HS_FDS_RECOVERY_ACCOUNT to default of «RECOVER»

setting HS_FDS_RECOVERY_PWD to default value

setting HS_FDS_TRANSACTION_LOG to default of HS_TRANSACTION_LOG

setting HS_IDLE_TIMEOUT to default of 0

setting HS_FDS_TRANSACTION_ISOLATION to default of «READ_COMMITTED»

HOSGIP returned value of «UCS2» for HS_NLS_NCHAR

setting HS_FDS_TIMESTAMP_MAPPING to default of «DATE»

setting HS_FDS_DATE_MAPPING to default of «DATE»

setting HS_RPC_FETCH_REBLOCKING to default of «ON»

setting HS_FDS_FETCH_ROWS to default of «100»

setting HS_FDS_RESULTSET_SUPPORT to default of «FALSE»

setting HS_FDS_RSET_RETURN_ROWCOUNT to default of «FALSE»

setting HS_FDS_PROC_IS_FUNC to default of «FALSE»

setting HS_FDS_MAP_NCHAR to default of «TRUE»

setting HS_NLS_DATE_FORMAT to default of «YYYY-MM-DD HH24:MI:SS»

setting HS_FDS_REPORT_REAL_AS_DOUBLE to default of «FALSE»

setting HS_LONG_PIECE_TRANSFER_SIZE to default of «65536»

setting HS_SQL_HANDLE_STMT_REUSE to default of «FALSE»

setting HS_FDS_QUERY_DRIVER to default of «TRUE»

setting HS_FDS_SUPPORT_STATISTICS to default of «FALSE»

setting HS_FDS_QUOTE_IDENTIFIER to default of «TRUE»

setting HS_KEEP_REMOTE_COLUMN_SIZE to default of «OFF»

setting HS_FDS_GRAPHIC_TO_MBCS to default of «FALSE»

setting HS_FDS_MBCS_TO_GRAPHIC to default of «FALSE»

Default value of 64 assumed for HS_FDS_SQLLEN_INTERPRETATION

setting HS_CALL_NAME_ISP to «gtw$:SQLTables;gtw$:SQLColumns;gtw$:SQLPrimaryKeys;gtw$:SQLForeignKeys;gtw$:SQLProcedures;gtw$:SQLStatistics;gtw$:SQLGetInfo;gtw$:OPTTables;gtw$:OPTColumns;gtw$:OPTPrimaryKeys;gtw$:OPTForeignKeys;gtw$:OPTProcedures;gtw$:OPTStatistics»

setting HS_FDS_DELAYED_OPEN to default of «TRUE»

setting HS_FDS_WORKAROUNDS to default of «0»

setting HS_WORKAROUNDS to default of «0»

Exiting hgosdip, rc=0

ORACLE_SID is «PG_LINK»

Product-Info:

  Port Rls/Upd:2/0 PrdStat:0

  Agent:Oracle Database Gateway for ODBC

  Facility:hsa

  Class:ODBC, ClassVsn:12.1.0.2.0_0023, Instance:PG_LINK

Exiting hgogprd, rc=0

hostmstr:          0: HOA After hoagprd

hostmstr:          0: HOA Before hoainit

Entered hgoinit

HOCXU_COMP_CSET=1

HOCXU_DRV_CSET=31

HOCXU_DRV_NCHAR=1000

HOCXU_DB_CSET=873

HS_LANGUAGE is american_america.we8iso8859p1

rc=32512 attempting to get LANG environment variable.

HOCXU_SEM_VER=121000

HOCXU_VC2_MAX=4000

HOCXU_RAW_MAX=2000

Entered hgolofn at 2015/10/20-15:04:11

HOSGIP for «HS_FDS_SHAREABLE_NAME» returned «/ora/dba/work/unixODBC/lib/libodbc.so»

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLAllocHandle

symbol_peflctx=0xdc741040

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLBindCol

symbol_peflctx=0xdc741180

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLBindParameter

symbol_peflctx=0xdc741970

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLCancel

symbol_peflctx=0xdc742c20

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLDescribeParam

symbol_peflctx=0xdc74adb0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLDisconnect

symbol_peflctx=0xdc74b220

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLEndTran

symbol_peflctx=0xdc74ddd0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLExecute

symbol_peflctx=0xdc74f420

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLFetch

symbol_peflctx=0xdc74fc10

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLFreeHandle

symbol_peflctx=0xdc7516a0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLFreeStmt

symbol_peflctx=0xdc7516c0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetData

symbol_peflctx=0xdc752cb0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetEnvAttr

symbol_peflctx=0xdc756050

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetFunctions

symbol_peflctx=0xdc7563c0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLMoreResults

symbol_peflctx=0xdc757e20

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLNumResultCols

symbol_peflctx=0xdc758a30

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLParamData

symbol_peflctx=0xdc758d50

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLPutData

symbol_peflctx=0xdc75ac30

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLRowCount

symbol_peflctx=0xdc75b060

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLSetEnvAttr

symbol_peflctx=0xdc75cfe0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLSetDescRec

symbol_peflctx=0xdc75cd90

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLColAttribute

symbol_peflctx=0xdc743720

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLColumns

symbol_peflctx=0xdc744f40

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLConnect

symbol_peflctx=0xdc748960

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLDescribeCol

symbol_peflctx=0xdc74a6c0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLDriverConnect

symbol_peflctx=0xdc74bda0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLExecDirect

symbol_peflctx=0xdc74ee50

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLForeignKeys

symbol_peflctx=0xdc750520

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetConnectAttr

symbol_peflctx=0xdc7519f0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetDescField

symbol_peflctx=0xdc7533d0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetDescRec

symbol_peflctx=0xdc753930

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetDiagField

symbol_peflctx=0xdc754c40

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetDiagRec

symbol_peflctx=0xdc755870

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetInfo

symbol_peflctx=0xdc756db0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetStmtAttr

symbol_peflctx=0xdc757060

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLGetTypeInfo

symbol_peflctx=0xdc757a90

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLPrepare

symbol_peflctx=0xdc7594d0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLPrimaryKeys

symbol_peflctx=0xdc7599e0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLProcedureColumns

symbol_peflctx=0xdc759fd0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLProcedures

symbol_peflctx=0xdc75a670

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLSetConnectAttr

symbol_peflctx=0xdc75b320

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLSetStmtAttr

symbol_peflctx=0xdc75e360

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLSetDescField

symbol_peflctx=0xdc75c9d0

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLStatistics

symbol_peflctx=0xdc75fc30

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Entered hgolofns at 2015/10/20-15:04:11

libname=/ora/dba/work/unixODBC/lib/libodbc.so, funcname=SQLTables

symbol_peflctx=0xdc760920

hoaerr:0

Exiting hgolofns at 2015/10/20-15:04:11

Exiting hgolofn, rc=0 at 2015/10/20-15:04:11

HOSGIP for «HS_OPEN_CURSORS» returned «50»

HOSGIP for «HS_FDS_FETCH_ROWS» returned «100»

HOSGIP for «HS_LONG_PIECE_TRANSFER_SIZE» returned «65536»

HOSGIP for «HS_NLS_NUMERIC_CHARACTERS» returned «.,»

HOSGIP for «HS_KEEP_REMOTE_COLUMN_SIZE» returned «OFF»

HOSGIP for «HS_FDS_DELAYED_OPEN» returned «TRUE»

HOSGIP for «HS_FDS_WORKAROUNDS» returned «0»

HOSGIP for «HS_FDS_MBCS_TO_GRAPHIC» returned «FALSE»

HOSGIP for «HS_FDS_GRAPHIC_TO_MBCS» returned «FALSE»

Invalid value of 64 given for HS_FDS_SQLLEN_INTERPRETATION

treat_SQLLEN_as_compiled = 1

Exiting hgoinit, rc=0 at 2015/10/20-15:04:11

hostmstr:          0: HOA After hoainit

hostmstr:          0: HOA Before hoalgon

Entered hgolgon at 2015/10/20-15:04:11

reco:0, name:csm_test, tflag:0

Entered hgosuec at 2015/10/20-15:04:11

Exiting hgosuec, rc=0 at 2015/10/20-15:04:11

HOSGIP for «HS_FDS_RECOVERY_ACCOUNT» returned «RECOVER»

HOSGIP for «HS_FDS_TRANSACTION_LOG» returned «HS_TRANSACTION_LOG»

HOSGIP for «HS_FDS_TIMESTAMP_MAPPING» returned «DATE»

HOSGIP for «HS_FDS_DATE_MAPPING» returned «DATE»

HOSGIP for «HS_FDS_MAP_NCHAR» returned «TRUE»

HOSGIP for «HS_FDS_RESULTSET_SUPPORT» returned «FALSE»

HOSGIP for «HS_FDS_RSET_RETURN_ROWCOUNT» returned «FALSE»

HOSGIP for «HS_FDS_PROC_IS_FUNC» returned «FALSE»

HOSGIP for «HS_FDS_REPORT_REAL_AS_DOUBLE» returned «FALSE»

using csm_test as default schema

HOSGIP for «HS_SQL_HANDLE_STMT_REUSE» returned «FALSE»

Entered hgocont at 2015/10/20-15:04:11

HS_FDS_CONNECT_INFO = «PG_LINK»

RC=-1 from HOSGIP for «HS_FDS_CONNECT_STRING»

Entered hgogenconstr at 2015/10/20-15:04:11

dsn:PG_LINK, name:csm_test

optn:

Entered hgocip at 2015/10/20-15:04:11

dsn:PG_LINK

Exiting hgocip, rc=0 at 2015/10/20-15:04:11

##>Connect Parameters (len=37)<##

## DSN=PG_LINK;

#! UID=csm_test;

#! PWD=*

Exiting hgogenconstr, rc=0 at 2015/10/20-15:04:11

Entered hgopoer at 2015/10/20-15:04:11

hgopoer, line 240: got native error 202 and sqlstate 08001; message follows…

[unixODBC]connction string lacks some options {08001,NativeErr = 202}

Exiting hgopoer, rc=0 at 2015/10/20-15:04:11

hgocont, line 2812: calling SqlDriverConnect got sqlstate 08001

Exiting hgocont, rc=28500 at 2015/10/20-15:04:11 with error ptr FILE:hgocont.c LINE:2832 ID:Something other than invalid authorization

Exiting hgolgon, rc=28500 at 2015/10/20-15:04:11 with error ptr FILE:hgolgon.c LINE:751 ID:Calling hgocont

hostmstr:          0: HOA After hoalgon

RPC Calling nscontrol(0), rc=0

hostmstr:          0: RPC Before Exit Agent

hostmstr:          0: HOA Before hoaexit

Entered hgoexit at 2015/10/20-15:04:11

Exiting hgoexit, rc=0

hostmstr:          0: HOA After hoaexit

hostmstr:          0: RPC After Exit Agent

Entered horcrces_CleanupExtprocSession at 2015/10/20-15:04:11

Entered horcrpooe_PopOciEnv at 2015/10/20-15:04:11

Entered horcrfoe_FreeOciEnv at 2015/10/20-15:04:11

Exiting horcrfoe_FreeOciEnv at 2015/10/20-15:04:11

Entered horcrfse_FreeStackElt at 2015/10/20-15:04:11

Exiting horcrfse_FreeStackElt at 2015/10/20-15:04:11

Exiting horcrpooe_PopOciEnv at 2015/10/20-15:04:11

Exiting horcrces_CleanupExtprocSession at 2015/10/20-15:04:11

Generated /tmp/sql.log file

$ more sql.log

[ODBC][13870][1445367851.328257][SQLSetConnectAttr.c][396]

                Entry:

                        Connection = 0x167eccc0

                        Attribute = SQL_ATTR_AUTOCOMMIT

                        Value = (nil)

                        StrLen = -5

[ODBC][13870][1445367851.328328][SQLSetConnectAttr.c][671]

                Exit:[SQL_SUCCESS]

[ODBC][13870][1445367851.328861][SQLDriverConnect.c][728]

                Entry:

                        Connection = 0x167eccc0

                        Window Hdl = (nil)

                        Str In = [DSN=PG_LINK;UID=csm_test;PWD=********][length = 37]

                        Str Out = 0x167eeda8

                        Str Out Max = 1024

                        Str Out Ptr = 0x7fffb8d3d3d0

                        Completion = 0

                UNICODE Using encoding ASCII ‘ANSI_X3.4-1968’ and UNICODE ‘UCS-2LE’

                DIAG [08001] connction string lacks some options

[ODBC][13870][1445367851.346106][SQLDriverConnect.c][1454]

                Exit:[SQL_ERROR]

[ODBC][13870][1445367851.346277][SQLGetDiagRec.c][686]

                Entry:

                        Connection = 0x167eccc0

                        Rec Number = 1

                        SQLState = 0x7fffb8d3d040

                        Native = 0x7fffb8d3cdf4

                        Message Text = 0x7fffb8d3ce00

                        Buffer Length = 510

                        Text Len Ptr = 0x7fffb8d3cdf2

[ODBC][13870][1445367851.346325][SQLGetDiagRec.c][723]

Exit:[SQL_SUCCESS]

                        SQLState = 08001

                        Native = 0x7fffb8d3cdf4 -> 202

                        Message Text = [[unixODBC]connction string lacks some options]

[ODBC][13870][1445367851.346404][SQLGetDiagRec.c][686]

                Entry:

                        Connection = 0x167eccc0

                        Rec Number = 2

                        SQLState = 0x7fffb8d3d040

                        Native = 0x7fffb8d3cdf4

                        Message Text = 0x7fffb8d3ce00

                        Buffer Length = 510

                        Text Len Ptr = 0x7fffb8d3cdf2

[ODBC][13870][1445367851.346438][SQLGetDiagRec.c][723]

                Exit:[SQL_NO_DATA]

[ODBC][13870][1445367851.346579][SQLDisconnect.c][208]

                Entry:

                        Connection = 0x167eccc0

[ODBC][13870][1445367851.346614][SQLDisconnect.c][237]Error: 08003

[ODBC][13870][1445367851.346714][SQLFreeHandle.c][284]

                Entry:

                        Handle Type = 2

                        Input Handle = 0x167eccc0

[ODBC][13870][1445367851.346748][SQLFreeHandle.c][333]

                Exit:[SQL_SUCCESS]

[ODBC][13870][1445367851.348941][SQLFreeHandle.c][219]

                Entry:

                        Handle Type = 1

                        Input Handle = 0x167d9f30

  • Remove From My Forums
  • Вопрос

  • I’m running CentOS 7. I installed the Microsoft ODBC Driver 11 for SQL Server on Linux. I also installed the unixODBC package and dependencies. I can ping the SQL Server. I can telnet to the SQL server on port 1433. My config files read:

    /etc/odbcinst.ini

    [ODBC Driver 11 for SQL Server]
    Description=Microsoft ODBC Driver 11 for SQL Server
    Driver=/opt/microsoft/msodbcsql/lib64/libsmodbcsql-11-0.so.2270.0
    Threading=1
    UsageCount=1

    /etc/odbc.ini

    [baew-cms01]
    Driver=»ODBC Driver 11 for SQL Server»
    Server=tcp:172.21.24.29,1433
    Database=smnswr_certmgmt

    ~/.odbc.ini

    [MSSQLTest]
    Driver=ODBC Driver 11 for SQL Server
    Server=tcp:baew-cms01,1433

    [baew-cms01]
    Driver=»ODBC Driver 11 for SQL Server»
    Server=tcp:172.21.24.29,1433
    Database=smnsvr_certmgmt

    When I run «sqlcmd -U <user> -S baew-cms01,1433» (substituting user name) I get a password prompt, then I get:

    1>

    So I assume I’m connected, but I’m not sure. However, when I run «isql -v baew-cms01 <user> <password>» again substituting user and password, I get:

    [IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
    [ISQL]ERROR: Could not SQLConnect

    Can anyone help me determine why I can’t isql to the server?

    Thanks,
    Jack

Ответы

  • Hi Jack,

    Please check these simillar posrts… this may be helpful for you to fix this issue…

    https://social.msdn.microsoft.com/Forums/en-US/7322e80a-0145-4147-b073-0e5aa67487d9/trying-to-connect-to-mssql-2012-from-linux-using-ad-and-sqlcmd?forum=sqldataaccess

    https://social.msdn.microsoft.com/Forums/en-US/a5402622-b4bd-417c-9168-bf55214c540c/connecting-to-sql-server-from-linux?forum=sqldataaccess


    Raju Rasagounder Sr MSSQL DBA

    • Помечено в качестве ответа

      1 декабря 2014 г. 15:02

  • I get a password prompt, then I get:

    1>

    So I assume I’m connected, but I’m not sure. However, when I run «isql -v baew-cms01 <user> <password>» again substituting user and password, I get:

    Hello Jack,

    Yes, when you get such a «1>» prompt, then you are connected to SQL Server.

    Please note, isql is deprecated, better use SqlCmd. But if you want to use iSql, then you have to use the -S Parameter for the Server Name, not -v. See isql Utility for all
    Parameters.


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Помечено в качестве ответа
      Simon_HouMicrosoft contingent staff
      1 декабря 2014 г. 15:02

This is a minimal but complete example how to connect to Azure SQL Database with isql from Ubuntu 14.04.1 LTS. The example is extracted from How To Connect Azure SQL Database From Ubuntu (disclaimer: it’s my personal wiki).

Install necessary packages

$ sudo apt-get -y install freetds-bin tdsodbc unixodbc

Configure FreeTDS

File /etc/freetds/freetds.conf

[global]
tds version = 7.1

[<SERVERNAME>]
host = <HOST>.database.windows.net
port = 1433

Test connection

At this point connecting with tsql should work:

$ tsql -S <SERVERNAME> -U <USERNAME>@<HOST> -P <PASSWORD>

Note that @<HOST> is required. Otherwise the connection ends with an error:

Msg 40531 (severity 11, state 1) from [<SERVERNAME>] Line 1:
    "Server name cannot be determined.  It must appear as the first segment of the server's dns name (servername.database.windows.net).  Some libraries do not send the server name, in which case the server name must be included as part of the user name (username@servername).  In addition, if both formats are used, the server names must match."
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

Configure ODBC driver

File /etc/odbcinst.ini

[FreeTDS]
Description = FreeTDS Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

Configure ODBC data sources

File /etc/odbc.ini

[<DATA_SOURCE_NAME>]
Driver = FreeTDS
Servername = <SERVERNAME>
Port = 1433
Database = <DBNAME>

<SERVERNAME> is the same than in freetds.conf.

Connect with isql

$ isql -v <DATA_SOURCE_NAME> <USER>@<HOST> <PASSWORD>
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select current_timestamp
+------------------------+
|                        |
+------------------------+
| 2015-01-02 09:05:55.593|
+------------------------+
SQLRowCount returns 1
1 rows fetched
SQL>

Note that @<HOST> is required. Otherwise the connection ends with an error:

[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[37000][unixODBC][FreeTDS][SQL Server]Server name cannot be determined.  It must appear as the first segment of the server's dns name (servername.database.windows.net).  Some libraries do not send the server name, in which case the server name must be included as part of the user name (username@servername).  In addition, if both formats are used, the server names must match.
[ISQL]ERROR: Could not SQLConnect

This is my configuration. I have a redhat 6.6 x64, I need to use it to connect to a remote Ms SQL 2008 database server via odbc/jdbc. I have another setup with Windows 2008r2 as client connection to the same MS SQL 2008 server so I knew the ip, password,
connectivity are setup correctly on the SQL server side.

I had successfully install the driver manager and odbc drivers for Microsoft ODBC Driver 11 For SQL Server for Linux.

the result of command   odbcinst -q -d -n «ODBC Driver 11 for SQL Server»  is

[ODBC Driver 11 for SQL Server]
Description=Microsoft ODBC Driver 11 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so
Threading=1
UsageCount=1

The result of command /usr/bin/odbcinst -q –j is

unixODBC 2.3.0
DRIVERS…………: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size…….: 8
SQLLEN Size……..: 8
SQLSETPOSIROW Size.: 8

the result of   bcp -v

BCP — Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 11.0.2270.0

So far so good.

my odbc.ini is

[ACADB]
Driver = ODBC Driver 11 for SQL Server
Server = jdbc:10.30.8.34,1433
Database = ACADB
[ACADB1]
Driver = ODBC Driver 11 for SQL Server
Server = tcp:10.30.8.34,1433
Database=ACADB
[ACADB3]
Driver = ODBC Driver 11 for SQL Server
Server = jdbc:10.30.8.34,1433
Database = ACADB

with the correct password, I can ‘login’ to my db but the prompt is kind of strange, it should be SQL> instead of number>.

NO trans-SQL command is been accepted there. The only command that worked was EXIT.

Note protocol used is jdbc not tcp. Using tcp as protocol would just give me error, see below.

[root@paaapdm1 etc]# sqlcmd  -S10.30.8.34  -dACADB -Uptevw
Password:
1>

sqlcmd  -S10.30.8.34  -dACADB1 -Uptevw
Password:
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Cannot open database «ACADB1» requested by the login. The login failed..
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login failed for user ‘ptevw’..

[root@paaapdm1 etc]# sqlcmd  -S10.30.8.34  -dACADB3 -Uptevw
Password:
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Cannot open database «ACADB3» requested by the login. The login failed..
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login failed for user ‘ptevw’..

I might be onto something but I can not verify if the drivers are working properly. Since I can not verify if the connection is working right, there is really no point for me to proceed with testing using my program which was written in Peoplecode.

Any advice will be greatly appreciated. TIA

Ed


First published on MSDN on Jan 22, 2014

While connecting to SQL from client application(running on linux server),  using using ‘SQL Native client 11.0 (ODBC) driver for Linux’ we were getting following error message.

Error message

[root@axxxxxazureapi]#  isql -v< DSN> <USERNAME> <PASSWORD>

[IM004][unixODBC][Driver Manager]Driver’s SQLAllocHandle on SQL_HANDLE_HENV failed

[ISQL]ERROR: Could not SQLConnect

In my case the issue is related with wrong installation path of the sqlncli dll. when we were trying to connect to SQL from Linux the application is trying to get the dll from a different path.

The best way to get the root cause is to take ODBC trace while issue is happening. It will give you more details about the failing API.

Before getting the trace check the UnixODBC version with following command:

odbcinst –j from linux command prompt and verified that unixODBC 2.3.0 (exactly that version, not older or newer) is installed.

Output is following:

$ odbcinst -j

unixODBC 2.3.0

DRIVERS…………: /etc/odbcinst.ini

SYSTEM DATA SOURCES: /etc/odbc.ini

FILE DATA SOURCES..: /etc/ODBCDataSources

USER DATA SOURCES..: /home/odbcuser/.odbc.ini

SQLULEN Size…….: 8

SQLLEN Size……..: 8

SQLSETPOSIROW Size.: 8

How to get the ODBC trace:

The ODBC Driver for SQL Server on Linux supports tracing of ODBC API call entry and exit.

To trace your application behavior, first add the following line to the odbcinst.ini file:

Trace=Yes

Then start your application with strace. For example:

strace -t -f -o trace_out.txt executable

In place of executable just use the command that you are using to run your application. In our case it is like following.


strace -t -f -o trace_out.txt isql -v <DSN>< USERNAME> <PASSWORD>

Once you get the error check the trace file. It will give you more information about the connection failure. On that basis you can troubleshoot the issue.

In my case the path of sqlncli.dll is not found because the application is pointing to a different path and the sqlncli.dll was installed to a different location. After moving the file to that location our application was working fine.


Author : Mukesh(MSFT), Suport engineer, Microsoft


Reviewed by : Snehadeep(MSFT), SQL Developer Technical Lead, Microsoft

Понравилась статья? Поделить с друзьями:
  • Ispring free cam ошибка экспорта
  • Ispring free cam ошибка initialize
  • Ispmanager server or network error
  • Ispmanager roundcube database error connection failed
  • Ispmanager http error 500