Re: what am I missing?
Konrad J Hambrick <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Organization | PayPlus Software, Inc |
| Message-ID | <[email protected]> |
Chris --
Oops ... I did not notice that you were trying to use ODBC ...
Are you able connect via DBI:Sybase instead of ODBC ?
Below is a short perl test program I use to test connection
parameters on our customer's servers ...
It invokes DBD::Sybase instead of going thru ODBC.
-- kjh
################################# cut here ################################
#!/usr/bin/perl
#
use strict ;
use warnings ;
use DBI ;
if ( $#ARGV < 2 )
{
print STDERR "usage: $0 Host User Pass\n" ;
exit( 1 );
}
my $TarHost = $ARGV[0] ; shift ;
my $TarUser = $ARGV[0] ; shift ;
my $TarPass = $ARGV[0] ; shift ;
my $LastMess = "" ;
my $DBH = DBI->connect( "DBI:Sybase:loginTimeout=5:server=$TarHost",
$TarUser,
$TarPass,
{ PrintError => 1,
AutoCommit => 1, # B01015-00 Default = 1
} );
unless ( $DBH )
{
$LastMess = ( $DBI::errstr != '' ) ? $DBI::errstr : "no DBI::errstr" ;
print STDERR "cannot access TarHost = $TarHost ... Error = $LastMess\n" ;
exit( 1 ) ;
}
my $Param = 99 ; # bind this
my $Result = 0 ; # get this back
my $STH = $DBH->prepare( "select ?" ) ;
$STH->bind_param( 1, $Param );
if ( ! $STH->execute )
{
$LastMess = ( $DBI::errstr != '' ) ? $DBI::errstr : "no DBI::errstr" ;
print STDERR "cannot execute the SQL Query ... Error = $LastMess\n" ;
exit( 1 ) ;
}
$Result = $STH->fetchrow_array ;
$STH->finish ;
print "Query Result = $Result\n" ;
exit( 0 ) ;
################################# cut there ################################
Chris Bartram wrote, On 05/24/2011 06:42 AM:
>
> The destination host in my case is Microsoft SQL (2005 cluster); but I did try
> with both a dbi:ODBC:nameinfreetds.conf; as well as the
> dbi:ODBC:DRIVER={freetds};server=sqlservclus.domain.org (also tried IP address
> instead of the hostname). Same errors...
>
> Using the tsql program though I can make a connection and retrieve data from the
> database just fine??
>
> -Chris
>
> "The purpose of life is not to be happy. It is to be useful, to be honorable,
> to be compassionate, to have it make some difference that you have lived and
> lived well". (Ralph Waldo Emerson)
>
>
>
>
> ________________________________
> From: Konrad J Hambrick<[email protected]>
> To: FreeTDS Development Group<[email protected]>
> Sent: Tue, May 24, 2011 5:33:58 AM
> Subject: Re: [freetds] what am I missing?
>
>
> Chris --
>
> I believe Randy nailed it. Your DBI->connect() string must include
> the $TDSHOST ( the Name in Brackets in /usr/local/etc/freetds.conf ).
>
> Like so:
>
> If your freetds.conf contains a server config:
>
> [Win2k3]
> host = win2k3.kjh.lan
> port = 1433
> tds version = 8.0
>
> then your DBI->connect() string should be (note the server= in the connect
> string):
>
> my $dbh = = DBI->connect( "DBI:Sybase:maxConnect=100:server=Win2k3",
> $TDSUser,
> $TDSPass,
> { PrintError => 0,
> # Option #1
> AutoCommit => 1,
> # Option #2, etc
> } ) ;
>
> HTH
>
> -- kjh
>
> Randy Syring wrote, On 05/23/2011 11:10 PM:
>> Try TDSDUMPCONFIG to see all the connection params that TDS is using.
>>
>> http://www.freetds.org/userguide/logging.htm
>>
>> I don't see a server name or IP address, might that be the issue?
>>
>> --------------------------------------
>> Randy Syring
>> Intelicom
>> Direct: 502-276-0459
>> Office: 502-212-9913
>>
>> For the wages of sin is death, but the
>> free gift of God is eternal life in
>> Christ Jesus our Lord (Rom 6:23)
>>
>>
>> On 05/23/2011 11:51 PM, Chris Bartram wrote:
>>> Thanks! Took care of the Perl .so loading issues...
>>>
>>> /usr/local/bin/tsql connection now working; I can connect and query data that
>>> way.
>>>
>>> Perl dbi:ODBC fails with following error codes:
>>>
>>> DBI connect('SQLServer','user',...) failed: [unixODBC][FreeTDS][SQL
>>> Server]Unable to connect to data source (SQL-08001) [state was 08001 now
>> 01000]
>>> [unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed (SQL-01000)
>>> [unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server (SQL-01000) at
>>> ./testscom.pl line 9
>>>
>>> Source looks like this:
>>>
>>> $dbh = DBI->connect("dbi:ODBC:SQLServer","user",$userpass);
>>>
>>> (also tried the DRIVER={};Server= format; same errors.)
>>>
>>> Target server is a SQL 2005 cluster; default instance – not a named
>>> instance.Calling from perl on a RHEL system.
>>>
>>>
>>> Any suggestions?
>>>
>>> -Chris Bartram
>>> "The purpose of life is not to be happy. It is to be useful, to be
>>> honorable,
>>> to be compassionate, to have it make some difference that you have lived and
>>> lived well". (Ralph Waldo Emerson)
>>>
>>>
>>>
>>>
>>> ________________________________
>>> From: James K. Lowden<[email protected]>
>>> To: [email protected]
>>> Sent: Wed, May 18, 2011 11:04:43 PM
>>> Subject: Re: [freetds] what am I missing?
>>>
>>> On Tue, 17 May 2011 19:30:17 -0700 (PDT)
>>> Chris Bartram<[email protected]> wrote:
>>>
>>>> When I try the ODBC connection in a Perl program I get
>>>> errors that the .so is not found; yet an ls shows the file(s) right
>>>> where it's supposed to be looking. tsql looks like it might be
>>>> working?
>>> http://www.freetds.org/91/userguide/linker.how.htm
>>>
>>> If Perl says it can't find the .so, it's telling the truth. Because
>>> Perl::DBI is using dlopen(3), nothing in the Perl executable nor the
>>> DBI library affects where the runtime linker looks. You have to tell
>>> it. LD_LIBRARY_PATH is your friend, but you may have to resort to
>>> LD_PRELOAD.
>>>
>>> HTH.
>>>
>>> --jkl
>>> _______________________________________________
>>> FreeTDS mailing list
>>> [email protected]
>>> http://lists.ibiblio.org/mailman/listinfo/freetds
>>> _______________________________________________
>>> FreeTDS mailing list
>>> [email protected]
>>> http://lists.ibiblio.org/mailman/listinfo/freetds
>> _______________________________________________
>> FreeTDS mailing list
>> [email protected]
>> http://lists.ibiblio.org/mailman/listinfo/freetds
>
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>