Why is Perl's DBI failing to connect to my cataloged DB2 database? - perl

I've downloaded the IBM DBI package, including all the packages in my program as specified in the docs. I've cataloged the DB and can connect to it from the command line, but my DBI connect fails:
$dbh = DBI->connect ("dbi:DB2:warehou1", user, pass) or die "Can't connect to sample database: $DBI::errstr";
Can't connect to sample database: [IBM][CLI Driver] SQL1031N The database directory cannot be found on the indicated file system. SQLSTATE=58031

Consider using the full connection string when DBI can't resolve a simple database name:
my $string = "dbi:DB2:DATABASE=$db; HOSTNAME=$hostname; PORT=$port; PROTOCOL=TCPIP; UID=$user; PWD=$pass;";
my $dbh = DBI->connect($string, $user, $pass) || die "Connection failed with error: $DBI::errstr";

Related

Deleted the DB2 Service Credentials. Created new credentials. New username and password not recognized for connection

#I'm using IBM DB2 on the cloud service (lite) of IBM. I deleted the DB2 Service Credentials but I didn't get to save the original password and username. I deleted that credential and created a new one. But using the ibm_db commands from python notebooks and sql to connect to the database, an error occurs:
SQLCODE=-30082ct: [IBM][CLI Driver] SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001
I've tried repeatedly deleting and creating new service credentials but same error occurs. Not sure if I need the original or something. Is there a way to implement the password change without access to the original?
I use the following python code using a jupyter notebook. I assign the dsn_driver and others as a string e.g. dsn_uid = "abc1234".
import ibm_db
dsn = (
"DRIVER={0};"
"DATABASE={1};"
"HOSTNAME={2};"
"PORT={3};"
"PROTOCOL={4};"
"UID={5};"
"PWD={6};"
"SECURITY={7};").format(dsn_driver, dsn_database, dsn_hostname, dsn_port, dsn_protocol, dsn_uid, dsn_pwd,dsn_security)
try:
conn = ibm_db.connect(dsn, "", "")
print ("Connected to database: ", dsn_database, "as user: ", dsn_uid, "on host: ", dsn_hostname)
except:
print ("Unable to connect: ", ibm_db.conn_errormsg() )
RESULTS:

Connecting Perl SQL Server 2017 - problem with multiple connections

I have a problem with connection (with Perl) to SQL Server 2017, it is strange because it works only for the 2 first records (it's a foreach loop), then it breaks in error (with SQL Server 2016 it works). Anyone know if there is some restriction/particularity with SQL Server 2017 (Express)?
The code is reported below (which works well only for the 2 first records).
my $DSN = 'driver={SQL Server};Server=GS PC\SQLEXPRESS;Database=RedBeryl;Trusted_Connection=yes';
$dbh = DBI->connect("DBI:ODBC:$DSN",{RaiseError=>1}) or die "$DBI::errstr\n";
and this is the error:
DBI connect('driver={SQL
Server};Server=GS-PC\SQLEXPRESS;Database=RedBeryl;Trusted_Connection=yes','HASH(0x487ae28)',...)
failed: Unable to fetch information about the error at
diamond_SQL2017.pl line 291.
Unable to fetch information about the error

Perl SFTP password authentication issues using Net::SFTP::Foreign. Pyt error. permission deny

I'm using Net::FTP::Foreign with password authentication. and I get error about pty and permission error. firstly, cannot connect to pty slave. secondly, Foreign seems not use password authentication mode. IO:Pty is installed. the machine is solaris.
Code:
my %args = (password => 'pwd', user => 'usr', port => 22, more => '-v');
log->info("Starting SFTP...\n");
my $sftp = Net::SFTP::Foreign->new($O->{sftp_server}, %args);
is there any wrong with my script or any configuration issue on my server.
thanks
Log:
warning: TIOCSCTTY failed, slave might not be set as controlling
terminal: Inappropriate ioctl for device at
/usr/pkgs/Export/US/SunOS5.10_i86pc/lib/perl5/CPAN/i86pc-solaris/IO/Pty.pm
line 121. Error: could not connect pty as controlling terminal! ssh:
tty: node name or service name not known Uncaught exception from user
code: Unable to establish SFTP connection: SSH slave exited
unexpectedly with error code 255 at
/usr/pkgs/Export/OPS/SunOS5.10_i86pc/cbin/mkt_daily_new_issue_download.pl
line 162 at
/usr/pkgs/Export/US/SunOS5.10_i86pc/lib/perl5/CPAN/Net/SFTP/Foreign/Common.pm
line 103
Net::SFTP::Foreign::Common::die_on_error('Net::SFTP::Foreign=HASH(0x84cfa78)',
'Unable to establish SFTP connection') called at
/usr/pkgs/Export/OPS/SunOS5.10_i86pc/cbin/mkt_daily_new_issue_download.pl
line 162

How to manage database connection to MySQL server in perl [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
MySQL server has gone away during crawling in Perl
I am using following script to create database connection to my mysql server.
my $dsn = "dbi:mysql:dbname=$dbname;$dbhost";
my $dbh = DBI->connect(
$dsn, $dbuser,
$dbpasswd,
{
PrintError => 1,
Warn => 1,
AutoCommit => 1,
ShowErrorStatement => 1
}
);
The main script which usage this connection is a long running script. Sometime in the execution the program gets failed with error message.
MySQL server has gone away
I am new to Perl, and am not able to see any issue with the database connection.
Please take a look at this thread : http://www.perlmonks.org/?node_id=317168
This discusses the way to deal with "MySQL server has gone away" problem. Basically you would need to check the status of $dbh before firing your query.
$dbh ||= DBI->connect("connection string", "username", "password");

DB2 9.5 CREATE DATABASE fails with Error SQL0901N, SQLSTATE 58004

Installed DB2 on Windows Vista with Admin priviledges.
Now i cannot create any new databases.. it always fails with the following error:
db2 CREATE DATABASE N3000 AUTOMATIC STORAGE YES ON 'D:\DB2'
DBPATH ON 'D:\DB2'
SQL0901N Die SQL-Anweisung schlug aufgrund eines nicht schwer wiegenden
(nicht kritischen) Systemfehlers fehl. Nachfolgende SQL-Anweisungen können
verarbeitet werden. (Ursachencode: "Length in PD=0, LFD length=1176, DMS
length=1176".) SQLSTATE=58004
Any ideas how to fix this?
in db2 directory:
c:\program files\ibm\sqllib\bin
execute:
db2set DB2_CREATE_DB_ON_PATH=YES
db2stop
db2start
Ready, now you create DB2 Databases in any path!!!!
look this: http://www.db2ude.com/?q=node/54
The problem was caused by an antivirus policy and was unrelated to DB2.
The file "C0000000.CAT" has to be excluded.