Connect to MS SQL 2005 server from UNIX

Discussion in 'Perl Misc' started by Slickuser, Oct 23, 2008.

  1. Slickuser

    Slickuser Guest

    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 = (78) NUMBER = (41)
    Server xxx, database
    Message String: Server is unavailable or does not exist. at testSQL.pl
    line 17
    Cannot log into xxx
    Slickuser, Oct 23, 2008
    #1
    1. Advertising

  2. Slickuser

    Dan Rumney Guest

    On Oct 23, 2:53 pm, Slickuser <> 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 = (78) 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
    Dan Rumney, Oct 23, 2008
    #2
    1. Advertising

  3. Slickuser

    Slickuser Guest

    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).
    Slickuser, Oct 27, 2008
    #3
  4. Slickuser

    Slickuser Guest

    On Oct 23, 3:37 pm, Dan Rumney <> wrote:
    > On Oct 23, 2:53 pm,Slickuser<> 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
    Slickuser, Oct 27, 2008
    #4
  5. Slickuser

    J. Gleixner Guest

    Slickuser wrote:
    > On Oct 23, 3:37 pm, Dan Rumney <> wrote:
    >> On Oct 23, 2:53 pm,Slickuser<> 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?
    J. Gleixner, Oct 27, 2008
    #5
  6. Slickuser

    Slickuser Guest


    >
    > 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.
    Slickuser, Oct 28, 2008
    #6
  7. Slickuser

    J. Gleixner Guest

    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.
    J. Gleixner, Oct 28, 2008
    #7
  8. Slickuser

    Slickuser Guest

    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.
    Slickuser, Oct 28, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page