简体   繁体   中英

Error while connecting MS SQL server 2019 using Perl

I am using perl version 5.6.1 (which we are planning to migrate to higher version soon).I am able to connect MS Sql Server 2014 with the below piece of code whereas I am unable to connect MS SQL Server 2019 getting the error posted below Perl code for db connection testing:

use MSSQL::DBlib;
use MSSQL::Sqllib;

# MS SQL server 2014 the db gets connected using the below stmt where it is throwing error
# for sql server 2019
$dbSession = eval{ (sql_init('xx.xxx.xxx.xx,port no','user','password',"database")};
die "dbconnect.pl: Error at sql_init." if $@;

print "Db connected \n";

Error: DB-Library error 10013,severity 11: Invalid parameter in DB-Library function reference DB-Library error 10004,severity 9: Unable to connect:Sql server is unavailable or doesn't exist.SSL security error. OS error 772:Connection Open (SECDoClientHandshake());

How to resolve this issue in perl version 5.6.1

Forget about MSSQL::Dblib and MSSQL::Sqllib. Microsoft might have dropped backward compatibility for the low-level APIs that these Perl Modules use internally. But I am not an expert here.

One way to do make this possibly work is Perl module DBD::ODBC .

Install a system-wide ODBC data source with the Windows tool "odbcad32.exe". and reference this datasource ("ODBC DSN") by name (eg "mydsn") in your Perl Code.

Like this:

use DBI;
$dbh = DBI->connect('dbi:ODBC:DSN=mydsn', 'user', 'password');

Sorry I don't have time to explain in detail how all this needs to be set up.

And the fact that you are using Perl 5.6.1 might indicate that your Windows Platform (including that older version of Microsoft's ODBC codebase) might still be too old for MSSQL 2019.

Besides, ODBC will subtly rewrite your SQL calls in places. So expect some surprises. But this strategy is better than nothing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM