IBM DB2 Connection strings Example

We shall see a few common examples of IBM DB2 Connection strings

Standard

Server=<hostAddress>:<port Number>;Database=<data base name>;UID=<user name>;PWD=<password>;

Example

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;

KeywordDescription
ServerSpecifies the server name.
Use IPv4 notation or the IPv6 notation.
Example : (server_name|ip_address[:port])
DatabaseSpecifies the Database alias. The maximum size is 255 bytes.
 UIDSpecifies the user ID.
PWDSpecifies the user password

Additional Options

Additional options for defining the connection string

KeywordDefaultDescription
Connection Lifetime 60sAmount of time (in seconds) a connection can remain idle in the connection pool.
Timeout 0Specifies timeout in seconds to wait for a database connection to be established successfully. A value of 0 indicates that there is no time limit.
DBName Specifies the Database name.
Max Pool Size Specifies maximum pool size
Min Pool Size Specifies minimum pool size
PoolingTrue- Connection pooling enabled
False-Connection pooling disabled
CurrentSchema Specifies the schema to be used to qualify for the current connection.

Examples

Define Connection pooling

Enable

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;Pooling =true

Disable

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;Pooling =false

Define Connection Timeout

Define a Connection Timeout of 30 seconds,

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;Pooling =false; TimeOut =30

Connection Lifetime

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;Pooling =false; TimeOut =30 ; Connection Lifetime=60;

Specifying schema

Server=test.prod.net:1234;Database=DB;UID=Test;PWD=*;Pooling =false;TimeOut =30 ; Connection Lifetime=60;CurrentSchema= SchemaA;

Hope this helps you!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *