Specify the following connection information to connect to the database.
Server=127.0.0.1;Port=26500;Database=mydb;User Id=myuser;Password=myuser01;...; (1) (2) (3) (4) (5) (6)
(1) Specify the host name or IP address of the server to be connected. This must be specified.
(2) Specify the port number for the database server. The default is "26500".
(3) Specify the database name to be connected.
(4) Specify the user ID that will connect with the database.
(5) Specify the password for the user that will connect to the database.
(6) Refer to the following for information on how to specify other connection information.
The following shows the keywords that are available to specify in the connection string in .NET Data Provider (Npgsql):
Note that some settings require care if using an Oracle database-compatible feature (refer to "9.2.2 Notes when Integrating with the Interface for Application Development" for details).
Keyword | Default value | Description |
---|---|---|
Server, Host | None | Specify the host name or IP address of the server to be connected. Specify up to 63 bytes when specifying a host name. A host name or IP address must be specified. |
Port | 26500 | Specify the port number for the database server. |
User Id, | None | Specify the user ID that will connect with the database. |
Password, Pwd, Psw | None | Specify the password for the user ID that will connect to the database. |
Database, DB | User name | Specify the database name to be connected. |
SearchPath | (*2) | Specify the default schema name of the SQL statements used in the application. *2: If omitted, the value set in the search_path parameter in postgresql.conf on the server will be used. |
Timeout | 15 | Specify the timeout for connections. Specify a value between 0 and 1024 (in seconds). There is no limit if you specify 0. The default is 15 seconds. An error occurs when a connection cannot be established within the specified time. |
ConnectionLifeTime | 15 | For specifying the retention time of the connection, starting from the time of connection to the server and including the period the connection is to be retained in the connection pool. Specify in the range between 0 and 2147483647 (in seconds). If "0" is specified, there will be no limit on the retention time. |
Pooling | True | Specify whether to use connection pooling or not.
Connection pooling is not used if you specify False. |
MaxPoolSize | 20 | Maximum size of a connection pool. If the request exceeds this limit, it will wait until the another connection closes and the pool is available. Specify in the range between 0 and 1024. Connection pooling is not used if you specify 0. |
MinPoolSize | 1 | Minimum size of a connection pool. When you specify MinPoolSize, NpgsqlConnection will pre-allocate connections with the specified number of servers. Specify in the range from 0 to the value specified at MaxPoolSize. When you specify 0, NpgsqlConnection will not pre-allocate connections with the specified number of servers. |
SSL | False | Specify whether to encrypt the communication route between the client and server with the SSL protocol.
|
Sslmode | Disable | Specify one of the following values for the SSL connection control mode:
|
Enlist | True | Specify whether to have connections participate in transactions with the transaction scope declared:
|
CommandTimeout | 20 | Specify the timeout for communication with the server. Specify a value between 0 and 2147483647 (in seconds). There is no limit set if you set 0 or a negative value. The default is 20 seconds. An error occurs when data is not received from the server within the specified time. |
Compatible | (*3) | Any effects from operational changes when performing future Npgsql version upgrades can be kept to a minimum by specifying the version of Npgsql that Fujitsu Npgsql .NET Data Provider is based on. Refer to the Installation and Setup Guide for Client for the version of Npgsql that Fujitsu Npgsql .NET Data Provider is based on. *3: If omitted, the version of Npgsql that Fujitsu Npgsql .NET Data Provider is based on will be set. |
IntegratedSecurity | False | Set this when using Windows Integrated Security. |
Protocol | 3 | Specify the protocol version to use. You must specify 3. |
SyncNotification | False | Specify whether Npgsql will use synchronized notification. |
Use Extended Types, UseExtendedTypes | False | This option determines how Nqgsql data and time types are used by DataAdapter. Data and time types include the "System.DateTime" type of .NET and "NpgsqlTimeStamp" ("NpgsqlTimeStamp" has functionality and range that exceeds "System.DateTime"). Both can be used, whatever value is set. If the value set is "True", however, it is possible to pass a specific Npgsql type for the relevant field of DataAdapter. If the value set is "False", on the other hand, DataAdapter requests "System.DateTime". |
PreloadReader, Preload Reader | False | If True is specified, the entire result set will be loaded to DataReader before ExecuteReader() returns. Performance may decline when "True" is set (especially noticeable when the recordset is large). According to ADO.NET documentation, other operations are not possible while IDbConnection is being used, as it is used to get IDataReader. Npgsql enforces this rule. While NpgsqlDataReader is open, most operations except for the NpgsqlDataReader on the NpgsqlConnection that is trying to get the NpgsqlConnection will return an InvalidOperationException. (If NpgsqlDataReader is called at the end of the resultset(s), then Npgsql relaxes the rules and allows use of the connection even if it is not closed. This is because the connection is not being used by any resources at this point.) |
*1: Only those keywords listed below can be used when using NpgsqlConnectionStringBuilder.
Host
UserName
Password
Database
UseExtendedTypes
PreloadReader