Global Data Management Forum

 View Only

 How can I connect to a DB2 zOS database using IBM.EntityFrameworkCore?

Orlando Alvarez's profile image
Orlando Alvarez posted Wed February 19, 2025 03:16 PM

Greetings, Data Management Community.

I've been trying to connect to a DB2 zOS database, for which I have a license installed. I have no problems when trying to access the database from IBM's Data Studio, so I would like to know how to properly specify the license in a ASP.NET Core 8.0 web API, since I get an error while debugging.

ERROR [42968] [IBM] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

I have tried adding a folder called "License" in the main project, where the .lic file is, and neither that or adding the file in the .nuget install folder did fix it either.

I should also mention there are other DB2 databases in the company, and I have no problem connecting my app to those, just this particular one. Since I'm working from Mexico and said database is managed by a USA team, checking in with the server for deeper details might be complicated, but I would like to know if there's anything I must do in the client side, aside from requesting another license from my local item shop.

Jesper Krommes's profile image
Jesper Krommes

The error message says

SQL1598N  An attempt to connect to the database server failed because of a licensing problem.
 
Explanation:
This message can be returned in the following situations:
Connecting directly to the database server using IBM DB2 Connect Unlimited Edition for System z
         If you use IBM DB2 Connect Unlimited Edition for System z to
         connect directly to the database server, this message is
         returned when a valid license has not been activated on the DB2
         for z/OS subsystem.
Connecting directly to the database server using an edition of IBM DB2 Connect other than IBM DB2 Connect Unlimited Edition for System z
         If you use an edition other than IBM DB2 Connect Unlimited  Edition for System z to connect directly to a database server,
         this message is returned when a valid license is not present on  the client computer.
Connecting to a database server through a DB2 Connect gateway server 
         If you connect to a database server through a DB2 Connect  gateway server, this message is returned when a valid license
         is not present on the DB2 Connect gateway server.
 
User response:
Respond to this message according to which scenario applies to your situation:
Connecting directly to the database server using IBM DB2 Connect Unlimited Edition for System z
         If you use IBM DB2 Connect Unlimited Edition for System z to  connect directly to the database server, activate the license
         by running the activation program in the activation kit.
Connecting directly to the database server using an edition of IBM DB2 Connect other than IBM DB2 Connect Unlimited Edition for System z
         If you use an edition other than IBM DB2 Connect Unlimited Edition for System z to connect directly to a database server,
         ensure that a DB2 Connect product and valid license key are installed on your client computer.
Connecting to a database server through a DB2 Connect gateway server
         If you connect to a database server through a DB2 Connect gateway server, ensure that a valid license key is installed on
         the gateway server.
sqlcode: -1598
sqlstate: 42968

You do not have a proper level of license for connecting to DB2 z/OS:
It is not the license for ASP.NET and a .lic file.
The ASP.NET might have a higher version of driver for connecting to DB2 z/OS than your old Data Studio.
You find versions and size for various driver versions here:
https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads

Her is how to activate a version 12.1 driver, which migth fix your problem:
https://www.ibm.com/docs/en/db2/12.1?topic=dswnls-activating-license-key-db2-connect-unlimited-edition-system-z

Have a nice day

Jesper Krommes
DBA since the start of DB2

Tapan Kumar Ghosh's profile image
Tapan Kumar Ghosh

Hi Orlando,

Could you please share the below details to understand the issue better.

-  What is the exact NuGet version of IBM Data Server provider for Entity Framework Core (i.e IBM.EntityFrameworkCore NuGet version) used in your ASP.NET Core 8.0 web application.

-  Which exact version of license file (.lic) have you copied under the "C:\Users\<username>\.nuget\packages\net.ibm.data.db2\8.0.0.X00\buildTransitive\clidriver\license" folder
Please share the license file name with us. Also open the *.lic file to share ProductVersion=xx.x contents in the license file.

Thanks,
Tapan

Chad Breiner's profile image
Chad Breiner

It sounds like to me you need to have a DB2 connect gateway license from where you are running from or a global DB2 Connect license installed on the subsystem.

Chad Breiner's profile image
Chad Breiner

I use DB2 Connect in one form or another everyday.  The only thing I have to do on my client is either ensure there is a global connect license installed on the db2 subsystem or I have a connect license for my client.  That should be the only thing you would need to connect to DB2 ZOS.