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=*;
Keyword | Description |
---|---|
Server | Specifies the server name. Use IPv4 notation or the IPv6 notation. Example : (server_name|ip_address[:port]) |
Database | Specifies the Database alias. The maximum size is 255 bytes. |
UID | Specifies the user ID. |
PWD | Specifies the user password |
Additional Options
Additional options for defining the connection string
Keyword | Default | Description |
---|---|---|
Connection Lifetime | 60s | Amount of time (in seconds) a connection can remain idle in the connection pool. |
Timeout | 0 | Specifies 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 | |
Pooling | True- 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.