MSSQL/ODBC connection, query hangs
My goal/problem is as follows:
I need to be able to automate connecting to and pulling data from the EMC Visual SRM database in order to be able to automate reports. The data I need access to is in a MSSQL database on a Windows Server 2003. The script to do so runs on a Redhat 5.2 VM.
I have installed freetbs v0.82
Here is my configuration:
/etc/odbc.ini:
[MSSQLServer]
Description = TDS MSSQL (PUSDATIN)
Driver = TDS
ServerName = TDS
Database =
UID = username
PWD =
Port = 1433
/etc/odbcinst.ini
[TDS]
Description = v0.60 With Protocol v8.0
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsS.so
FileUsage = 1
UsageCount = 2
[MSSQLServer]
Description = TDS MSSQL (PUSDATIN)
Driver = TDS
Servername = xxx.xxx.xxx.xxx
Database =
UID = username
PWD =
Port = 1433
/usr/local/etc/freetbs.conf:
[TDS]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.0
When I connect using isql and do a select * from a table, it returns only the first field from the first column.
I have a simple php script as a proof of concept to access the DB and do a query, but it hangs on the select:
$connect = odbc_connect("MSSQLServer", "srmreport", "srmreport") or die ("Couldn't connect");
print "connected\n";
odbc_exec($connect, "use Northwind");
print "exec use Northwind.\n";
$result = odbc_exec($connect, "SELECT CompanyName, ContactName " . "FROM Suppliers");
print "exec select\n";
while (odbc_fetch_row($result)) {
print(odbc_result($result, "CompanyName") .
' ' . odbc($result, "ContactName") . "\n");
}
odbc_free_result($result);
odbc_close($connect);
this is what happens when the script is executed:
php odbctest.php
connected
exec use Northwind.
and then it hangs
the last few lines of an strace of the execution show this:
poll([{fd=3, events=POLLOUT, revents=POLLOUT}], 1, -1) = 1
sendto(3, "\3\1\0\255\0\0\1\0\r\0s\0p\0_\0c\0u\0r\0s\0o\0r\0o\0p\0"..., 173, MSG_NOSIGNAL, NULL, 0) = 173
poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, -1) = 1
recvfrom(3, "\4\1\0\321\0f\1\0", 8, MSG_NOSIGNAL, NULL, NULL) = 8
poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, -1) = 1
recvfrom(3, "\201\3\0\0\0\10\0\347P\0\vC\0o\0m\0p\0a\0n\0y\0N\0a\0m\0e"..., 201, MSG_NOSIGNAL, NULL, NULL) = 201
poll(
a tcpdump between the VM and the Database server shows occasional
arp reply ...... (oui unknown)
I would be very grateful if someone can give any hints or clues as to why it may hang or suggest a method for finding the solution.
|