Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Difficulty Connecting to MS-SQL server in Linux

by MegaVoice (Novice)
on Jul 13, 2007 at 17:53 UTC ( [id://626496]=perlquestion: print w/replies, xml ) Need Help??

MegaVoice has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am currently trying to connect to a MS-SQL server in Linux. I have using the Sybase method to connect, but recently ran into an issue with a different server.

All of the previous servers have been straightforward, but this one has a slash in the name of the server. It is called ORCXPDB1C2\SQL. I add an additional slash in the server definition, but I am still having troubles connecting.

Here is the connection information:
use DBI;
my $user = "xyz";
my $passwd = "xyx2";
my $server = "ORCXPDB1C2\\SQL";
my $dbh = DBI->connect("DBI:Sybase:server=$server", $user, $passwd, {PrintError => 0});

If I connect to MS SQL servers without the slash, I can connect just fine with the above method. Not sure how to get around this issue.

Thank you!
  • Comment on Difficulty Connecting to MS-SQL server in Linux

Replies are listed 'Best First'.
Re: Difficulty Connecting to MS-SQL server in Linux
by derby (Abbot) on Jul 13, 2007 at 18:03 UTC

    A backslash in the name? (not slash - I'll never forgive ms for co-opting the definition of slash). I would recommend posting to The Daily WTF. Rather than some technical solution, I would recommend editing the interfaces file to set a more reasonable name for the server.

    -derby

    Update: The servername here is not the dns servername but the handle within the interfaces file (which could map to one or more actual machines). Looking at the documentation for Sybase, it appears a backslash is not a valid character for a servername. Now this may be one of those funky places where MS and Sybase diverged but since you're using the Sybase client, then Sybase rules would apply.

    From the sybase manual for ASE 12.5:
    servername
    Name of Adaptive Server or Backup Server. Requirements for a server name are:
    * The name cannot be more than 30 characters long.
    * The first character must be a letter (ASCII a through z, A through Z).
    * The characters that follow must be letters, numbers, or underscores (_).

    Update (again): I should know better than to answer Sybase questions. Always listen to mpeppler or jfroebe before me! See mpeppler's correct answer below (but I stand by the slash heresy comment! And, the servername requirements apply but that's not the case here.)

Re: Difficulty Connecting to MS-SQL server in Linux
by mpeppler (Vicar) on Jul 14, 2007 at 06:35 UTC
    I believe you are trying to connect to what is known as a named instance. This was recently added to FreeTDS (supported by FreeTDS in the current release, I think). If you don't have the latest version of FreeTDS you should probably upgrade (or ask on the FreeTDS mailing list.)

    Michael

      Michael,

      I am running the latest stable version of FreeTDS (0.64) and submitted a question to their mailing list. I might be able to connect via ODBC, but I remain hopeful that the FreeTDS mailing list might have some insight.

      Thank you,
      Sean
        Got it! I had the host that the server resided on. I was able to update the connection string to the following:

        my $dbh=DBI->connect("DBI:Sybase:host=<hostname>;port=2832",$user,$password);

        Since the hostname didn't have a slash in it, I was able to use the port that the server was using. I was able to connect so that I can continue testing.

        I appreciated the comments!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://626496]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found