Skip to Content.
Sympa Menu

freetds - [freetds] DSQUERY as an IP vs a DSN

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Andy Clark" <andy AT abednegosystems.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] DSQUERY as an IP vs a DSN
  • Date: Sat, 14 Dec 2002 17:41:20 -0700

Hello everyone. I have recently inherited a hybrid Linux/SQL Server web
site and I am in the process of trying to set up a test system, but I
having trouble getting the FreeTDS/DBD-Sybase connections to work the
way they are used in the production site. I will confess up front that
I am something of a novice on the Linux side and I'm sure I am just
missing something easy, but I'm not sure where to look. I'll try to
explain the issue adequately (following your published guidelines), but
I would be happy to provide any additional info as needed.

First, here is some basic setup and config info:
1. Web server: RedHat 7.1, Apache 1.3.19
2. Data server: NT 4, SQL Server 7.0
3. FreeTDS version: 0.60
4. DBD-Sybase version: 0.94
5. Perl 5.6

Second, here is the behavior:
Having successfully verified the basic connectivity by following the
tsql steps as outlined in the FreeTDS documentation, I wrote a simple
test script that would test a basic page-based connection and also a
second connection that more closely represents the way the connections
are used throughout the site code. This script is generating the same
errors as the copies of the production pages running on the test system.

Basically, this part works fine:
# test a basic connection without using the config.ini file
print "<p><b>Attempting a FreeTDS/DBD-Sybase connection without the
config.ini file...</b></p>\n";
$ENV{DSQUERY}="MSSQL"; #this line seems to be the key
my $dbh = DBI->connect('dbi:Sybase:database=mydb', 'user', 'password');
my $sth = $dbh->prepare("select count(*) from
information_schema.tables");
if($sth->execute) {
while(@dat = $sth->fetchrow) {
print "Connection successful - the number tables is:
@dat<br><br><br>\n";
}
}

But this part doesn't:
# test a connection using the config file
print "<p><b>Attempting to connect using the config file and retrieve a
table list...</b></p>\n";
my $database = "/mydir/config.ini";
open(OPTIONS,"$database");
my @options = <OPTIONS>;
close(OPTIONS);
my $pwd2 = pop(@options);
my $usr2 = pop(@options);
my $pwd = pop(@options);
my $usr = pop(@options);
my $ip = pop(@options);
chomp($ip);
chomp($usr);
chomp($pwd);
chomp($usr2);
chomp($pwd2);
$ENV{DSQUERY}=$ip; #this line seems to be the key
$dbh = DBI->connect('dbi:Sybase:database=mydb', $usr, $pwd);
$sth = $dbh->prepare("select * from information_schema.tables");
if($sth->execute) {
while(@dat = $sth->fetchrow) {
print "@dat<br>\n";
}
}

For the second snippet, the error is something like "Connect failed"
from DBI. The main factor seems to be whether DSQUERY is assigned the
value for the data server IP or the DSN defined in the Sybase interfaces
file - when I assigned DSQUERY to the DSN name ("MSSQL" in this case) it
works, but if I assign it to the server IP like the production site
pages do, it fails to connect.

Some additional info:
1. I traced out the parsed values from the config file and they are all
there just as they should be (i.e., $usr = 'user', $pwd = 'password',
etc), so the file is accessible and is being read and parsed correctly.
At least it seems to be.
2. A basic test swapping out the DSQUERY value and just testing the
DBI->connect line gives the same results (i.e., it works with the DSN
name, but not with the IP)
3. The config.ini file is a simple text file that holds the user,
password and IP for use by all pages in the site. Vlaues are parsed
form the file and fed in as params to make it easy to change them as
needed.

Third here is the question: How does DSQUERY affect the connection
process and what is the difference between the DSN value vs the IP
value? The basics seem to be in place, but I can't recreate the
production functionality - what am I missing?

Any help you can provide would be greatly appreciated.





Archive powered by MHonArc 2.6.24.

Top of Page