- Print
- DarkLight
- PDF
Connection Strings
The connections strings found in your configuration file, holds the information on how the API will connect to your database. These settings are DBMS dependant, meaning that there are different details for Microsoft and Oracle.
See the chapter “Database connection” on how to configure your first database connection.
In case you have version 7.3 or earlier version of the API please refer to this Application Settings page. In case you are installing a newer version, then this page is for you.
Default, connection string.
In your “Connections Strings” configuration there need to be at least one database connection. This is typically given the JSON property name, or key “Default”. The API will use this connection unless instructed to do otherwise.
Multiple database connection strings.
The API support multiple database connection string. Where each is identified by its own JSON property name or key. Each database connection could connect to the same or different server, database and using different database user to connect.
The calling application needs to identify the database connection to use during the endpoint call. If no such instruction is given, the API will use the “Default, connection string.”
The application calling the API can identify the connection string to use by adding to the URL this parameter:
- ConnectionStringKey=default
- Here the application is instructing the API to use the “default” connection string.
- ConnectionStringKey=default_ora
- Here the application is instructing the API to use the “default_ora” connection string.
Example:
appsettings.json file content:
"ConnectionStrings": {
"default": "Data Source=127.0.0.1:1521/SafranDatabase;User Id=SAFRANSA;Password=safran;Max Pool Size=200;",
SafranDatabase
"default_mss": "Server=127.0.0.1;Database=SafranDatabase;User Id=SAFRANSA;Password=safran;",
"default_ora": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SafranDatabase)));User Id=SAFRANSA;Password=safran;"
},
Calling the Safran API endpoint with specified database connection string key:
https://mySafranAPI/v1/codesets?id=9&ConnectionStringKey=default_mss&meta_field_select=r1
Your database connection string key cannot contain the character “.” (dot), when using the “JSON Web Token” as per the “Security” setting. Meaning when having the “authentication mode” setting is set to “jsonwebtoken”.
The Safran ILAP Gateway supports one database connection. Make sure your connection string host the "default" setting.
Make sure that the user specified in the connection string has access to run DBMS specific SQL as outlined in "Installation" and "Additional database test".
Additional connection string parameters
In addition to what is shown in the chapter “Database connection” other parameters can be provided, as per what your DBMS support.
- Oracle has one called “Max Pool Size”:
- "default": "Data Source=MyServer:1521/TestBase1;User Id=SAFRANSA;Password=safran;Max Pool Size=200;"
- Sample of additional Oracle parameters
- "default": "Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=2;"
Oracle TNS-less connection string
Typically, your Oracle connection string will use what is called TNS names (Transparent Network Substrate), which means you will have to configure your Oracle client installation. TNS refers to the network layer that facilitates communication between clients (such as applications or tools) and Oracle database servers. It handles tasks like resolving service names to connection details, managing connections, and routing requests. Essentially, TNS enables seamless communication over the network.
This can be avoided by using TNS-less connection string. By using such connection string, there is no need to add configuration in to your “tnsnames.ora” file.
Also see the Glossary.
"ConnectionStrings": {
"default": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;"
},
Oracle connection string, content
The Oracle connection string typically involves the following items:
- Data Source: Specifies the Oracle database location. It can be an Oracle service name, an Oracle SID (System Identifier), or a TNS (Transparent Network Substrate) alias.
- User Id (or User Name): The username used to authenticate with the Oracle database.
- Password: The corresponding password for the specified user.
- Provider: The data provider used to connect to Oracle. For example:
- ODP.NET (Oracle Data Provider for .NET)
- OLE DB Provider
- ODBC (Oracle Database Connectivity)
- Connection Pooling Parameters (optional):
- Min Pool Size: Minimum number of connections in the pool.
- Max Pool Size: Maximum number of connections in the pool.
- Connection Lifetime: Maximum time a connection can remain in the pool.
- Connection Timeout: Maximum time to wait for a connection from the pool.
- Incr Pool Size: Number of connections added when needed.
- Decr Pool Size: Number of connections removed when not needed.
- Additional Parameters (optional):
- DBA Privilege: For privileged connections (e.g., SYSDBA, SYSOPER).
- Integrated Security: For Windows authentication.
- Pooling: Enable or disable connection pooling.
- Enlist: Enable or disable automatic enlistment in distributed transactions.