NTiConnection
class
Description
The NTiConnection
class represents the connection to the IBM i and implements the DbConnection
class from the ADO.NET model (System.Data.Common
namespace).
General considerations
Connection Pool
NTi does not implement a connection pool. It is up to the user to implement it in .NET if necessary. In this way, the user has total control over the connections he opens and closes, without delegating this work to a randomly operating connection pool.
💡 It is relatively simple to implement a custom object pool in .NET. For example, use this mechanism using
ConcurrentBag<T>
to implement your own connection pool.
One instance = one TCP connection = one IBM i job
Each instance of NTiConnection
carries one TCP socket instance to connect to the IBM i. Thus there is a strong link between the instance, the connection and the IBM i job.
When an instance of NTiConnection
is explicitly destroyed via .NET's Garbage Collector, the underlying TCP connection is instantly closed and destroyed in turn, causing the IBM i job to stop. This mechanism guarantees total user control of connections.
Connection string
Like most database access providers, NTi uses a connection string to obtain IBM i connection information (user name, password, etc.). This connection string may contain sensitive information. There are a number of methods for securing the management of the connection string and configuration files.
Refer to the official .NET documentation and recommendations for their implementation.
ADO.NET implementation
This class implements the usual methods and properties of the ADO.NET model for carrying out database access operations, in particular
Open()
Close()
CreateCommand()
BeginTransaction()
Commit()
Rollback()
In this way, NTi integrates into any existing application developed with other vendors such as ODBC or OleDB drivers.
💡 Documentation for this default implementation can be found on any ADO.NET documentation, for example via the
System.Data.Common
namespace documentation.
Methods
In addition to the functionality of the ADO.NET model, the NTiConnection
class implements methods specific to the use of the IBM i, in particular for executing CL commands and calling RPG, CL... programs.
These specific methods are:
Method | Description |
---|---|
ChangeDatabase(string database) |
Sets the current library for the database session. |
ExecuteClCommand(string command) |
Executes the CL command given in the command parameter. |
CallProgram(string library, string program) |
Executes the program program from the library library. |
CallProgram(string library, string program, List< NTiProgramParameter > parameters) |
Executes the library library program program with the parameters passed. |
Properties
The specific properties of the NTiConnection
class allow you to define connection properties and access information about the state of the connection to the IBM i. To ensure compatibility with other providers' connection strings, some properties may correspond to several different keywords.
Property | Keyword in the connection string | Type | Description |
---|---|---|---|
Server |
server or system or dsn or datasource or data source |
string |
IP address or domain name of the IBM i on the network |
Username |
user or user id or userid or uid |
string |
IBM i account username |
Password |
password |
string |
IBM i account password |
DefaultDatabase |
default database or default collection |
string |
Default IBM i library (database only) |
UseSSL |
ssl or tls |
bool |
Using an SSL/TLS encrypted connection |
Untrusted |
untrusted |
bool |
Force the use of SSL even in the event of an error during certificate verification |
SignonPort |
signon port |
short |
Signon service port (QZDASOSIGN) |
DatabasePort |
database port |
string |
Database service port (QZDASOINIT) |
CommandPort |
command port |
string |
Port for orders and programmes service (QZRCSRVS) |
MapperPort |
mapper port |
string |
Port relative to the port mapping service (449 by default) |
UseDefaultPorts |
use default ports |
bool |
Whether or not to use [default ports] (https://www.ibm.com/support/pages/tcpip-ports-required-ibm-i-access-and-related-functions ‘Default ports for IBM i TCP/IP services’) |
UsePortsMapper |
use port mapper |
bool |
Whether or not to use the port mapping service. Enable this feature if the port numbers of different services are likely to change over time |
LicenseLibrary |
license library |
string |
The licence library to be used. By default, the KNTI library is used. |
BlockingFactor |
blocking factor |
string |
Number of records to be preloaded when retrieving a result |
ForceTranslate |
force translate |
int |
CCSID to be used to force translation of binary data into text (BINARY => CHAR, VARBINARY => VARCHAR, BLOB => CLOB) |
ConnectionString |
string |
Connection string used to define the connection parameters before the connection is established. Available keywords can be found in this article. | |
Messages |
string |
read only | |
ServerVersion |
string |
read only Target IBM i OS version | |
LOBMaxSize |
string |
Size threshold in bytes for using pointers to retrieve LOB type fields (from 0 to 2000000) | |
RetreiveSuccessMessages |
bool |
Whether or not to retrieve success messages detailed in the Messages property |
|
DataSource |
string |
Name of the target IBM i relational database | |
DecFloatRoundMode |
NTiRoundOption (enum) |
Rounding method for DECFLOAT numbers to more than 34 significant digits: - HalfEven Round to nearest digit, nearest even digit if equal - HalfUp Rounded to the nearest digit, to the excess if equal - Down Troncature - Ceiling Round to +infinity - Floor round to -infinity - HalfDown Round to nearest digit, truncate if equal - Up Rounded to excess |