Search code examples
freetdsunixodbcpervasive-sql

UnixODBC Cannot Query Pervasive SQL Database


I am using Ubuntu 14.04 on a VM to try and connect to a Pervasive SQL (V12) database hosted on a Windows 10 machine.

I have tested the networking and I can telnet into the pervasive server with:

telnet 192.168.0.2 1583

But when it comes to using isql/tsql/osql I just cannot get a connection to the Pervasive server so that I can query the database.

I have spent four weeks on this and gotten to the point now where it almost works.

So when running this command in terminal:

[email protected]:~# TDSDUMPCONFIG=stderr TDSDUMP=stderr tsql -S PSQL -U admin -P MASTER

I get the following output:

log.c:167:Starting log file for FreeTDS 0.95.95
    on 2016-05-20 10:11:02 with debug flags 0x4fff.
config.c:168:Getting connection information for [PSQL].
config.c:172:Attempting to read conf files.
config.c:353:... $FREETDSCONF not set.  Trying $FREETDS/etc.
config.c:366:... $FREETDS not set.  Trying $HOME.
config.c:296:Found conf file '/root/.freetds.conf' (.freetds.conf).
config.c:495:Looking for section global.
config.c:554:   Found section global.
config.c:557:Got a match.
config.c:580:   tds version = '4.2'
config.c:886:Setting tds version to 4.2 (0x402).
config.c:580:   dump file = '/tmp/freetds.log'
config.c:580:   timeout = '10'
config.c:580:   connect timeout = '10'
config.c:580:   text size = '64512'
config.c:554:   Found section psql.
config.c:568:   Reached EOF
config.c:495:Looking for section PSQL.
config.c:554:   Found section global.
config.c:554:   Found section psql.
config.c:557:Got a match.
config.c:580:   host = '192.168.0.2'
config.c:617:Found host entry 192.168.0.2 
config.c:620:IP addr is 192.168.0.2.
config.c:580:   port = '1583'
config.c:580:   client charset = 'UTF-8'
config.c:635:tds_parse_conf_section: client charset is UTF-8.
config.c:580:   tds version = '5.0'
config.c:886:Setting tds version to 5.0 (0x500).
config.c:568:   Reached EOF
config.c:300:Success: [PSQL] defined in /root/.freetds.conf.
config.c:765:Setting 'dump_file' to 'stderr' from $TDSDUMP.
config.c:213:Final connection parameters:
config.c:214:            server_name = PSQL
config.c:215:       server_host_name = 192.168.0.2
config.c:218:                ip_addr = 192.168.0.2
config.c:223:          instance_name = 
config.c:224:                   port = 1583
config.c:225:          major_version = 5
config.c:226:          minor_version = 0
config.c:227:             block_size = 0
config.c:228:               language = us_english
config.c:229:         server_charset = 
config.c:230:        connect_timeout = 10
config.c:231:       client_host_name = sails.dev
config.c:232:         client_charset = UTF-8
config.c:233:              use_utf16 = 0
config.c:234:               app_name = TSQL
config.c:235:              user_name = admin
config.c:238:                library = TDS-Library
config.c:239:              bulk_copy = 0
config.c:240:      suppress_language = 0
config.c:241:          encrypt level = 0
config.c:242:          query_timeout = 10
config.c:245:               database = 
config.c:246:              dump_file = stderr
config.c:247:            debug_flags = 0
config.c:248:              text_size = 64512
config.c:249:     emul_little_endian = 0
config.c:250:      server_realm_name = 
config.c:251:             server_spn = 
config.c:252:                 cafile = 
config.c:253:                crlfile = 
config.c:254:     check_ssl_hostname = 1
log.c:167:Starting log file for FreeTDS 0.95.95
    on 2016-05-20 10:11:02 with debug flags 0x4fff.
locale is "en_ZA.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
iconv.c:328:tds_iconv_open(0x641370, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:346:setting up conversions for client charset "UTF-8"
iconv.c:348:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:395:preparing iconv for "ISO-8859-1" <-> "ISO-8859-1" conversion
iconv.c:400:tds_iconv_open: done
net.c:202:Connecting to 192.168.0.2 port 1583 (TDS version 5.0)
net.c:275:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:314:tds_open_socket() succeeded
packet.c:740:Sending packet
0000 02 00 02 00 00 00 00 00-73 61 69 6c 73 2e 64 65 |........ sails.de|
0010 76 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |v....... ........|
0020 00 00 00 00 00 00 09 61-64 6d 69 6e 00 00 00 00 |.......a dmin....|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 05 4d 41-53 54 45 52 00 00 00 00 |......MA STER....|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 06 36 32 33-33 00 00 00 00 00 00 00 |.....623 3.......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 04 03 01 06 0a-09 01 00 00 00 00 00 00 |........ ........|
0090 00 00 00 00 54 53 51 4c-00 00 00 00 00 00 00 00 |....TSQL ........|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 04 50 53 51 4c 00-00 00 00 00 00 00 00 00 |...PSQL. ........|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 04 00 06 4d 41 53 54-45 52 00 00 00 00 00 00 |....MAST ER......|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 08 05 00 00 00 54 44-53 2d 4c 69 62 72 61 72 |......TD S-Librar|
01e0 0a 05 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|

packet.c:740:Sending packet
0000 02 01 00 65 00 00 00 00-00 00 00 00 00 00 0a 00 |...e.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0030 00 00 00 00 00 00 00 00-00 00 00 00 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-e2 1a 00 01 0b 08 00 01 |........ ........|
0050 e8 0f 6d 7f ff ff ff fe-02 0b 00 00 00 00 00 00 |..m..... ........|
0060 02 68 00 00 00         -                        |.h...|

token.c:327:tds_process_login_tokens()
query.c:3772:tds_disconnect() 
mem.c:648:tds_free_all_results()
util.c:165:Changed query state from IDLE to WRITING
util.c:165:Changed query state from WRITING to PENDING
packet.c:740:Sending packet
0000 0f 01 00 0a 00 00 00 00-71 00                   |........ q.|

token.c:550:tds_process_tokens(0x641370, 0x7ffee7182238, 0x7ffee718223c, 0x100)
util.c:165:Changed query state from PENDING to READING
query.c:3772:tds_disconnect() 
util.c:165:Changed query state from READING to DEAD
token.c:565:processing result tokens.  marker is  0()
token.c:116:tds_process_default_tokens() marker is 0()
token.c:119:leaving tds_process_default_tokens() connection dead
util.c:83:logic error: cannot change query state from DEAD to PENDING
util.c:165:Changed query state from DEAD to DEAD
util.c:322:tdserror(0x63f400, 0x641370, 20056, 9)
util.c:358:tdserror: client library not called because either tds_ctx (0x63f400) or tds_ctx->err_handler is NULL
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
token.c:336:looking for login token, got  0()
token.c:116:tds_process_default_tokens() marker is 0()
token.c:119:leaving tds_process_default_tokens() connection dead
login.c:472:login packet accepted
util.c:322:tdserror(0x63f400, 0x641370, 20002, 0)
util.c:358:tdserror: client library not called because either tds_ctx (0x63f400) or tds_ctx->err_handler is NULL
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
mem.c:648:tds_free_all_results()
There was a problem connecting to the server

And I have no idea what to try next so that I can query the data in the database.

I have tried all tds versions, tds drivers and pervasive ODBC drivers to no avail.

Any insight into what can be acertained from the above log and/or what I might be doing wrong would be greatly appreciated, thank you!


Solution

  • Create a ClientDSN usind dsnadd (docs).

    Once the DSN is set up, test using the psql user and isql and then follow the instructions for "Using Utilities from Users Other than psql" for using another user. As noted in comments, copy the contents of /home/psql/.bashrc to the /root/.bashrc.