Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Connect to MS SQL 2005 server from UNIX

Reply
Thread Tools

Connect to MS SQL 2005 server from UNIX

 
 
Slickuser
Guest
Posts: n/a
 
      10-23-2008
Hi,

I'm trying to connect to MS SQL 2005 server from UNIX. But I get the
warning below.

I can connect through C#.NET fine using the same server, user &
password.
Any idea why?

Here's the perl code:

#!/usr/local/bin/perl

use strict;
use warnings;

use DBI;

my $server = "xxx";
my $user = "xxx";
my $password = "xxx";
my $dbname = "xxx";


my @available_drivers = DBI->available_drivers;
print ("The available DBD drivers are: @available_drivers.\n");

my $dbh = DBI->connect("dbi:Sybase:$server", "$user", "$password")
or die "Cannot log into $server\n";



login> perl testSQL.pl
The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER = (0)
ORIGIN = (0) SEVERITY = (7 NUMBER = (41)
Server xxx, database
Message String: Server is unavailable or does not exist. at testSQL.pl
line 17
Cannot log into xxx
 
Reply With Quote
 
 
 
 
Dan Rumney
Guest
Posts: n/a
 
      10-23-2008
On Oct 23, 2:53*pm, Slickuser <(E-Mail Removed)> wrote:
<snip>
>
> login> perl testSQL.pl
> The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
> Sponge Sybase mysql.
> src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
> DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER = (0)
> ORIGIN = (0) SEVERITY = (7 NUMBER = (41)
> Server xxx, database
> Message String: Server is unavailable or does not exist. at testSQL.pl
> line 17
> Cannot log into xxx


This isn't really a Perl question, since the problem you're having is
with the connection to your database.

If I were getting this problem, the first thing I'd check is that port
4000. Is that the correct port?
I'd also look at my Sybase docs and try and determine what the LAYER,
ORIGIN, SEVERITY, NUMBER messages meant.

Hope that helps, but you probably want to be talking to some Sybase
people about this issue, not Perl
 
Reply With Quote
 
 
 
 
Slickuser
Guest
Posts: n/a
 
      10-27-2008
I tried the specific port (1433) and get this error:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
testSQL.p



If I tried the IP then I get this:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
at
Cannot log into xx.xx.xx.xx,1433

On windows, I can connect fine to using ODBC with ip or server name
(no port or with port 1433).
 
Reply With Quote
 
Slickuser
Guest
Posts: n/a
 
      10-27-2008
On Oct 23, 3:37*pm, Dan Rumney <(E-Mail Removed)> wrote:
> On Oct 23, 2:53*pm,Slickuser<(E-Mail Removed)> wrote:
> <snip>
>


> This isn't really a Perl question, since the problem you're having is
> with the connection to your database.
>
> If I were getting this problem, the first thing I'd check is that port
> 4000. Is that the correct port?
> I'd also look at my Sybase docs and try and determine what the LAYER,
> ORIGIN, SEVERITY, NUMBER messages meant.
>


I tried to use the specific port but it doesn't work either.

Here's the log:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
testSQL.p



The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
at
Cannot log into xx.xx.xx.xx,1433

 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      10-27-2008
Slickuser wrote:
> On Oct 23, 3:37 pm, Dan Rumney <(E-Mail Removed)> wrote:
>> On Oct 23, 2:53 pm,Slickuser<(E-Mail Removed)> wrote:
>> <snip>
>>

>
>> This isn't really a Perl question, since the problem you're having is
>> with the connection to your database.
>>
>> If I were getting this problem, the first thing I'd check is that port
>> 4000. Is that the correct port?
>> I'd also look at my Sybase docs and try and determine what the LAYER,
>> ORIGIN, SEVERITY, NUMBER messages meant.
>>

>
> I tried to use the specific port but it doesn't work either.
>
> Here's the log:
>
> The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
> Sponge Sybase mysql.
>
> DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
> testSQL.p
>
>
>
> The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
> Sponge Sybase mysql.
>
> DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
> at
> Cannot log into xx.xx.xx.xx,1433
>


Can you connect to the port on that server from your machine?

telnet your.server.name 1433

Does the database allow connections from your machine for that username
and password?
 
Reply With Quote
 
Slickuser
Guest
Posts: n/a
 
      10-28-2008

>
> Can you connect to the port on that server from your machine?
>
> telnet your.server.name 1433
>


I cannot by telnet.

> Does the database allow connections from your machine for that username
> and password?


I can log-in with provided user&password from Win32:ODBC or Microsoft
SQL management from Windows side.
 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      10-28-2008
Slickuser wrote:
>> Can you connect to the port on that server from your machine?
>>
>> telnet your.server.name 1433
>>

> I cannot by telnet.


Just to be clear. You don't get a connection using telnet? e.g.
you don't see..

Trying some.ip.ad.dress...
Connected to some.machine.name
Escape character is '^]'.

You can't actually do anything via telnet, however it should
connect to the port. If it doesn't then "there's your problem
right there", or at least one of the problems. Contact
your Network/Firewall folks.

>
>> Does the database allow connections from your machine for that username
>> and password?

>
> I can log-in with provided user&password from Win32:ODBC or Microsoft
> SQL management from Windows side.


But, you're using a different machine running some flavor of Unix,
right? There are many reasons why connecting from another
machine/OS/IP wouldn't be allowed, none having to do with Perl.
 
Reply With Quote
 
Slickuser
Guest
Posts: n/a
 
      10-28-2008
On Oct 28, 10:53*am, "J. Gleixner" <glex_no-s...@qwest-spam-
no.invalid> wrote:
> Slickuser wrote:
> >> Can you connect to the port on that server from your machine?

>
> >> telnet your.server.name 1433

>
> > I cannot by telnet.

>
> Just to be clear. You don't get a connection using telnet? e.g.
> you don't see..
>
> Trying some.ip.ad.dress...
> Connected to some.machine.name
> Escape character is '^]'.
>
> You can't actually do anything via telnet, however it should
> connect to the port. *If it doesn't then "there's your problem
> right there", or at least one of the problems. Contact
> your Network/Firewall folks.
>
>
>


If I do > telnet server 1433
I have my command prompt windows title to be: "Telnet server" and the
cursor is blinking.


> >> Does the database allow connections from your machine for that username
> >> and password?

>
> > I can log-in with provided user&password from Win32:ODBC or Microsoft
> > SQL management from Windows side.

>
> But, you're using a different machine running some flavor of Unix,
> right? There are many reasons why connecting from another
> machine/OS/IP wouldn't be allowed, none having to do with Perl.


But this user/password has nothing to do Unix.
If I can connect from Windows using perl Win32 ODBC, C#.net SQL
command, and SQL Management (same user/password from SQL Database).
Then I should be able to connect through Unix with the same user/
password.

I still don't know why though.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remote connect to the SQL server 2005 when th ere is a‘\’ in the SQL server name, such as 192.168.0.1 1\active? Wesley Chen Ruby 9 04-14-2009 11:36 AM
How to remote connect to the SQL server 2005 when th ere is a‘\’ in the SQL server name, such as 192.168.0.1 1\active? Wesley Chen Ruby 0 04-07-2009 10:23 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Visual Studio .NET 2005 WebParts can't connect to SQL Server 2005 XJ ASP .Net 8 01-07-2008 08:51 AM
Wohoo! VS.NET 2005/ASP.NET 2.0/SQL Server 2005/BizTalk Server 2006 will launch week of Nov. 7 Juan T. Llibre ASP .Net 0 06-07-2005 05:19 PM



Advertisments