From: Evie on
I'm attempting to connect to a DB2 database using perl DBD::DB2. I'm
consistently getting the following error:

[IBM][CLI Driver] SQL1042C An unexpected system error occurred.
SQLSTATE=58004

What I have done:

Installed the DB2 client, registered the database and verified
connectivity using the db2 command line utility.

Verified the database with the following command:
my @data_sources = DBI->data_sources('DB2');
print "Data sources:\n\t", join("\n\t",@data_sources),"\n\n";

Data sources:
dbi:DB2:SBLDV1

Connect code:

$dbh = DBI->connect("dbi:DB2:SBLDV1", "sbldv1", "password") or
die "Can't connect to database: $DBI::errstr\n";

Output:

DBI connect('SBLDV1','sbldv1',...) failed: [IBM][CLI Driver] SQL1042C
An unexpected system error occurred. SQLSTATE=58004
at ./db2.pl line 28
Can't connect to database: [IBM][CLI Driver] SQL1042C An unexpected
system error occurred. SQLSTATE=58004

I'm at a loss as to how to move foward. All of the posts I've seen are
solved by either installing the client or registering the database -
both of which I've done.

From: kfbombar@us.ibm.com on
What platform is the DB2 Server on and what platform are you using the
client on? If the client is on Windows, please ensure that the system
variables are correctly pointing to DB2.

Evie wrote:
> I'm attempting to connect to a DB2 database using perl DBD::DB2. I'm
> consistently getting the following error:
>
> [IBM][CLI Driver] SQL1042C An unexpected system error occurred.
> SQLSTATE=58004
>
> What I have done:
>
> Installed the DB2 client, registered the database and verified
> connectivity using the db2 command line utility.
>
> Verified the database with the following command:
> my @data_sources = DBI->data_sources('DB2');
> print "Data sources:\n\t", join("\n\t",@data_sources),"\n\n";
>
> Data sources:
> dbi:DB2:SBLDV1
>
> Connect code:
>
> $dbh = DBI->connect("dbi:DB2:SBLDV1", "sbldv1", "password") or
> die "Can't connect to database: $DBI::errstr\n";
>
> Output:
>
> DBI connect('SBLDV1','sbldv1',...) failed: [IBM][CLI Driver] SQL1042C
> An unexpected system error occurred. SQLSTATE=58004
> at ./db2.pl line 28
> Can't connect to database: [IBM][CLI Driver] SQL1042C An unexpected
> system error occurred. SQLSTATE=58004
>
> I'm at a loss as to how to move foward. All of the posts I've seen are
> solved by either installing the client or registering the database -
> both of which I've done.

From: Evie on
Fixed it!

I had installed the regular client NOT the developer version of the
client. Perusing the log files helped with the diagnosis. I was
missing the required library files.


kfbombar(a)us.ibm.com wrote:
> What platform is the DB2 Server on and what platform are you using the
> client on? If the client is on Windows, please ensure that the system
> variables are correctly pointing to DB2.
>
> Evie wrote:
> > I'm attempting to connect to a DB2 database using perl DBD::DB2. I'm
> > consistently getting the following error:
> >
> > [IBM][CLI Driver] SQL1042C An unexpected system error occurred.
> > SQLSTATE=58004
> >
> > What I have done:
> >
> > Installed the DB2 client, registered the database and verified
> > connectivity using the db2 command line utility.
> >
> > Verified the database with the following command:
> > my @data_sources = DBI->data_sources('DB2');
> > print "Data sources:\n\t", join("\n\t",@data_sources),"\n\n";
> >
> > Data sources:
> > dbi:DB2:SBLDV1
> >
> > Connect code:
> >
> > $dbh = DBI->connect("dbi:DB2:SBLDV1", "sbldv1", "password") or
> > die "Can't connect to database: $DBI::errstr\n";
> >
> > Output:
> >
> > DBI connect('SBLDV1','sbldv1',...) failed: [IBM][CLI Driver] SQL1042C
> > An unexpected system error occurred. SQLSTATE=58004
> > at ./db2.pl line 28
> > Can't connect to database: [IBM][CLI Driver] SQL1042C An unexpected
> > system error occurred. SQLSTATE=58004
> >
> > I'm at a loss as to how to move foward. All of the posts I've seen are
> > solved by either installing the client or registering the database -
> > both of which I've done.