SQL0332N Character conversion from the source code page "" to the target code page "" is not supported

0

I am attempting to connect to an IBM DB2 database from a .NET 5 console application. This works fine against DB2 LUW in a local Docker instance, but fails when connecting to a z/OS mainframe instance.

Server:

  • IBM DB2 v11.5
  • z/OS

Client:

  • .NET 5 console application
  • IBM.Data.DB2.Core (v3.1.0.400)
  • IBM Data Server Driver (v11.5)

Error:

IBM.Data.DB2.Core.DB2Exception (0x80004005): ERROR [57017] [IBM] SQL0332N  Character conversion from the source code page "" to the target code page "" is not supported.  SQLSTATE=57017
    at IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
    at IBM.Data.DB2.Core.DB2Connection.Open()
    at <my code>

Connection string:

Database=<redacted>;User ID=<redacted>;Password=<redacted>;Server=<redacted>:448;Persist Security Info=True;CurrentSchema=<redacted>;Connect Timeout=30

Opening connection:

var connection = new DB2Connection(connectionString);

try
{
    connection.Open();
}
catch (DB2Exception e)
{
    logger.LogError("Unable to access DB2 instance");
    logger.LogError(e.ToString());

    throw new DbAccessAcception(e);
}

The DB user I am testing with is already in use by another .NET program to connect to this database, though that app is older (.NET Framework 3.5).

What I've tried:

  • Setting the code page to 1200, 1208, or 1252, using both the DB2CODEPAGE environment variable as well as the connection string CodePage parameter; nothing changed the error message
  • Verified all software (DB2, DB2 DSDRIVER, .NET provider) are v11.5
  • Verified I can connect and run queries with db2cli.exe

Now what? Is there somewhere I can/should be setting the DB2 server type? Eg, z/OS vs LUW? Note that I'm not using EntityFramework, just directly executing Commands on that Connection object (though the error comes before then).

c#
.net
db2
db2-zos
asked on Stack Overflow Mar 24, 2021 by Sam Jones • edited Mar 24, 2021 by Charles

1 Answer

0

We have solved the problem. There were two changes to make, which definitely complicated things.

  1. We did need to set the DB2CODEPAGE environment variable to 1208
  2. We were using the CurrentSchema connection string parameter to set the prefix for our SQL queries, but the prefix wasn't the actual schema, which broke the connection even when the right codepage was set, without a useful error message on the client. We removed that parameter and manually set the table prefix on our SQL queries.

Making both those changes got the application working.

Connecting to the local Docker instance had worked because I had set an actual schema for that prefix, not realizing the prod instance was configured differently.

answered on Stack Overflow Mar 26, 2021 by Sam Jones

User contributions licensed under CC BY-SA 3.0