2

I want to access to a SQL Anywhere database which is on another server. I can do it easily from Windows, but I need to do it from Debian now. All of this in php.

Windows side : I have installed SQL anywhere driver from https://archive.sap.com/documents/docs/DOC-35857, and connect with odbc:Driver={SQL Anywhere 16};Server=serveur-02;Port=2638;Database=excalib;Uid=username;Pwd=pwd; Ok, it works.

Debian side : I am on Debian 9 with php 7.0. UnixODBC is already installed and works with some others connections. FreeTDS is installed too. So I have make a link in odbcinst.ini :

[SQLAnywhere16]
Description     = SQLAnywhere driver
Driver  = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup   = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

And in odbc.ini :

[Excalibur]
Description     = Excalibur
Driver  = SQLAnywhere16
Server  = [ip]
Port    = 2638
Name    = excalib
User    = user
Password        = password

With command

isql -v Excalibur

I got

[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08004][unixODBC][FreeTDS][SQL Server]Erreur SQL Anywhere -83 : La base de 
donn▒es sp▒cifi▒e est introuvable
[ISQL]ERROR: Could not SQLConnect

As I understand, it reaches server, but don't find my database. Ok, it's encouraging. Maybe a typo mistake, but I can't find documentation which can tell me, maybe someone has a hint ?

Next step is to do it with php.

odbc:Driver={SQLAnywhere16};Server=[ip];Port=2638;Database=excalib;Uid=user;Pwd=pwd

And... it does nothing. I got nothing from my server (ERR_EMPTY_RESPONSE) There's nothing in apache's log. If I do a typo mistake on purpose on the driver path, it sends a correct error

Fatal error: Uncaught PDOException: SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so1' : file not found in /var/www/html/test.php:24 Stack trace: #0 /var/www/html/test.php(24): PDO->__construct('odbc:Driver={SQ...') #1 {main} thrown in /var/www/html/test.php on line 24

And... I'm lost. Someone can help me ? Or maybe has another solution to connect to SQLAnywhere database ?

Thank you.

Edit [thank to Nitrex] : When I try to connect via php, tcpdump doesn't capture anything, so I think the problem come from Debian side.

Nihiora
  • 21
  • 1
  • 5
  • Check if the port that SQL Anywhere is using is open from both windows and Debian side, I'm guessing port 2638 .. try Wireshark on Windows and tcpdump on Debian to check where the connection is cutting – nitrex Mar 07 '18 at 16:34
  • Thank you for your response Nitrex. It works properly when I log from `isql -v Excalibur`, but it gives me nothing when I try to do it with php... Good hint, we have to look on Debian side, we progress ! – Nihiora Mar 08 '18 at 08:27

0 Answers0