Ana içeriğe atla

General Information

Connection Type

database

UI Documentation

Endpoints

List Connections

GET /apiops/projects/{projectName}/connections/?type=database

Get Connection

GET /apiops/projects/{projectName}/connections/{connectionName}/

Create Connection

POST /apiops/projects/{projectName}/connections/{connectionName}/

Update Connection

PUT /apiops/projects/{projectName}/connections/{connectionName}/

Delete Connection

DELETE /apiops/projects/{projectName}/connections/{connectionName}/

List Connections

Endpoint

GET /apiops/projects/{projectName}/connections/?type=database

Request

Headers

HeaderValue
AuthorizationBearer

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
Note: The type query parameter is required to filter connections by type.

cURL Example

curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/" \
  -H "Authorization: Bearer YOUR_TOKEN"

Get Connection

Endpoint

GET /apiops/projects/{projectName}/connections/{connectionName}/

Request

Headers

HeaderValue
AuthorizationBearer

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Response

Success Response (200 OK)

{
  "success": true,
  "resultList": [
    {
      "type": "database",
      "name": "my-database-connection",
      "description": "Database connection for data storage",
      "deployToWorker": true,
      "enabled": true,
      "dbType": "POSTGRES",
      "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb",
      "useCredentials": true,
      "username": "dbuser",
      "databaseName": "mydb",
      "password": null,
      "initialPoolSize": 1,
      "minPoolSize": 1,
      "maxPoolSize": 5,
      "incrementCount": 1,
      "maxStatements": 100,
      "idleConnectionTestPeriod": 30000,
      "connectionTimeout": 30000,
      "testConnectionOnCheckout": true,
      "testConnectionOnCheckin": false,
      "maxConnectionAge": 180000,
      "maxIdleTime": 120000,
      "selectedEnvironmentId": null
    }
  ],
  "resultCount": 1
}
Note: Password is masked in get operations.

cURL Example

curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-database-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN"

Create Connection

Endpoint

POST /apiops/projects/{projectName}/connections/{connectionName}/

Request

Headers

HeaderValue
AuthorizationBearer
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Request Body

Full JSON Body Example - PostgreSQL Connection
{
  "type": "database",
  "name": "my-database-connection",
  "description": "PostgreSQL database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "POSTGRES",
  "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "mydb",
  "password": "dbpassword",
  "initialPoolSize": 1,
  "minPoolSize": 1,
  "maxPoolSize": 5,
  "incrementCount": 1,
  "maxStatements": 100,
  "idleConnectionTestPeriod": 30000,
  "connectionTimeout": 30000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 180000,
  "maxIdleTime": 120000,
  "selectedEnvironmentId": null
}
Full JSON Body Example - MySQL Connection
{
  "type": "database",
  "name": "my-mysql-connection",
  "description": "MySQL database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "MYSQL",
  "jdbcUrl": "jdbc:mysql://localhost:3306/mydb?useSSL=false",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "mydb",
  "password": "dbpassword",
  "initialPoolSize": 2,
  "minPoolSize": 2,
  "maxPoolSize": 10,
  "incrementCount": 2,
  "maxStatements": 200,
  "idleConnectionTestPeriod": 30000,
  "connectionTimeout": 30000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 180000,
  "maxIdleTime": 120000,
  "selectedEnvironmentId": null
}
Full JSON Body Example - Oracle Connection
{
  "type": "database",
  "name": "my-oracle-connection",
  "description": "Oracle database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "ORACLE",
  "jdbcUrl": "jdbc:oracle:thin:@localhost:1521:ORCL",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "ORCL",
  "password": "dbpassword",
  "initialPoolSize": 1,
  "minPoolSize": 1,
  "maxPoolSize": 5,
  "incrementCount": 1,
  "maxStatements": 100,
  "idleConnectionTestPeriod": 30000,
  "connectionTimeout": 30000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 180000,
  "maxIdleTime": 120000,
  "selectedEnvironmentId": null
}
Full JSON Body Example - MongoDB Connection
{
  "type": "database",
  "name": "my-mongodb-connection",
  "description": "MongoDB database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "MONGODB",
  "jdbcUrl": "jdbc:mongodb://localhost:27017/mydb",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "mydb",
  "password": "dbpassword",
  "initialPoolSize": 1,
  "minPoolSize": 1,
  "maxPoolSize": 5,
  "incrementCount": 1,
  "maxStatements": 100,
  "idleConnectionTestPeriod": 30000,
  "connectionTimeout": 30000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 180000,
  "maxIdleTime": 120000,
  "selectedEnvironmentId": null
}
Full JSON Body Example - High-Performance Pool
{
  "type": "database",
  "name": "my-high-performance-db",
  "description": "High-performance database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "POSTGRES",
  "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "mydb",
  "password": "dbpassword",
  "initialPoolSize": 5,
  "minPoolSize": 5,
  "maxPoolSize": 50,
  "incrementCount": 5,
  "maxStatements": 500,
  "idleConnectionTestPeriod": 60000,
  "connectionTimeout": 60000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 360000,
  "maxIdleTime": 300000,
  "selectedEnvironmentId": null
}
Request Body Fields
Common Fields
FieldTypeRequiredDefaultDescription
typestringYes-Connection type discriminator field. Identifies the connection type in API requests/responses.
namestringYes-Connection name (must match path parameter)
descriptionstringNo-Connection description
deployToWorkerbooleanNotrueWhether to deploy to worker
enabledbooleanNotrueWhether connection is enabled
Database-Specific Fields
FieldTypeRequiredDefaultDescription
dbTypestringYes-Database type. See EnumDatabaseType
jdbcUrlstringYes-JDBC connection URL
useCredentialsbooleanNotrueWhether to use username/password authentication
usernamestringNo-Database username (required if useCredentials=true)
databaseNamestringNo-Database name
passwordstringNo-Database password (required if useCredentials=true, secret field)
initialPoolSizeintegerNo1Initial number of connections in pool
minPoolSizeintegerNo1Minimum number of connections in pool
maxPoolSizeintegerNo5Maximum number of connections in pool
incrementCountintegerNo1Number of connections to add when pool grows
maxStatementsintegerNo100Maximum number of prepared statements per connection
idleConnectionTestPeriodintegerNo30000Period to test idle connections (milliseconds)
connectionTimeoutintegerNo30000Maximum time to wait for connection (milliseconds)
testConnectionOnCheckoutbooleanNotrueTest connection when checked out from pool
testConnectionOnCheckinbooleanNofalseTest connection when checked in to pool
maxConnectionAgeintegerNo180000Maximum age of connection before closing (milliseconds)
maxIdleTimeintegerNo120000Maximum idle time before closing connection (milliseconds)
selectedEnvironmentIdstringNonullSelected environment ID

EnumDatabaseType (dbType)

  • ORACLE - Oracle Database
  • MYSQL - MySQL Database
  • POSTGRES - PostgreSQL Database
  • SQL_SERVER - Microsoft SQL Server
  • SYBASE - Sybase Database
  • DB2 - IBM DB2 Database
  • APACHE_HIVE - Apache Hive
  • APACHE_IMPALA - Apache Impala
  • MONGODB - MongoDB (NoSQL)
  • TRINO - Trino (formerly PrestoSQL)

JDBC URL Examples

  • PostgreSQL: jdbc:postgresql://host:5432/database
  • MySQL: jdbc:mysql://host:3306/database
  • Oracle: jdbc:oracle:thin:@host:1521:SID or jdbc:oracle:thin:@host:1521/service
  • SQL Server: jdbc:sqlserver://host:1433;databaseName=database
  • MongoDB: jdbc:mongodb://host:27017/database

Notes

  • dbType and jdbcUrl are required.
  • useCredentials defaults to true. If false, username and password are not used.
  • username and password are required if useCredentials: true.
  • databaseName is optional but recommended for clarity.
  • Connection pool settings control connection management:
    • initialPoolSize - Connections created at startup
    • minPoolSize - Minimum connections maintained
    • maxPoolSize - Maximum connections allowed
    • incrementCount - Connections added when pool grows
  • Timeout values are in milliseconds:
    • idleConnectionTestPeriod - How often to test idle connections (default: 30000ms = 30 seconds)
    • connectionTimeout - Maximum wait for connection (default: 30000ms = 30 seconds)
    • maxConnectionAge - Maximum connection lifetime (default: 180000ms = 3 minutes)
    • maxIdleTime - Maximum idle time before closing (default: 120000ms = 2 minutes)
  • testConnectionOnCheckout: true validates connections before use (recommended).
  • testConnectionOnCheckin: false skips validation when returning connections (default).

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}

cURL Example

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-database-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "database",
    "name": "my-database-connection",
    "description": "PostgreSQL database connection",
    "deployToWorker": true,
    "enabled": true,
    "dbType": "POSTGRES",
    "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb",
    "useCredentials": true,
    "username": "dbuser",
    "databaseName": "mydb",
    "password": "dbpassword",
    "initialPoolSize": 1,
    "minPoolSize": 1,
    "maxPoolSize": 5,
    "incrementCount": 1,
    "maxStatements": 100,
    "idleConnectionTestPeriod": 30000,
    "connectionTimeout": 30000,
    "testConnectionOnCheckout": true,
    "testConnectionOnCheckin": false,
    "maxConnectionAge": 180000,
    "maxIdleTime": 120000
  }'

Update Connection

Endpoint

PUT /apiops/projects/{projectName}/connections/{connectionName}/

Request

Headers

HeaderValue
AuthorizationBearer
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name (must match name in body)

Request Body

Full JSON Body Example
{
  "type": "database",
  "name": "my-database-connection",
  "description": "Updated PostgreSQL database connection",
  "deployToWorker": true,
  "enabled": true,
  "dbType": "POSTGRES",
  "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb",
  "useCredentials": true,
  "username": "dbuser",
  "databaseName": "mydb",
  "password": "newpassword123",
  "initialPoolSize": 2,
  "minPoolSize": 2,
  "maxPoolSize": 10,
  "incrementCount": 2,
  "maxStatements": 200,
  "idleConnectionTestPeriod": 30000,
  "connectionTimeout": 30000,
  "testConnectionOnCheckout": true,
  "testConnectionOnCheckin": false,
  "maxConnectionAge": 180000,
  "maxIdleTime": 120000,
  "selectedEnvironmentId": null
}
Note: Request body structure is the same as Create Connection. All fields should be provided for update.

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [...]
  }
}

Delete Connection

Endpoint

DELETE /apiops/projects/{projectName}/connections/{connectionName}/

Request

Headers

HeaderValue
AuthorizationBearer

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [...]
  }
}

Notes and Warnings

  • Database Types:
    • Supports multiple database types via JDBC
    • Each database type has specific JDBC URL format
    • Ensure appropriate JDBC driver is available
  • JDBC URL:
    • Format varies by database type
    • Include connection parameters in URL if needed
    • Examples:
      • PostgreSQL: jdbc:postgresql://host:5432/database
      • MySQL: jdbc:mysql://host:3306/database?useSSL=false
      • Oracle: jdbc:oracle:thin:@host:1521:SID
  • Connection Pooling:
    • Connection pooling improves performance by reusing connections
    • initialPoolSize - Connections created at startup
    • minPoolSize - Minimum connections maintained (pool never goes below this)
    • maxPoolSize - Maximum connections allowed (pool never exceeds this)
    • incrementCount - Connections added when pool needs to grow
    • Balance pool size with database server capacity
  • Connection Validation:
    • testConnectionOnCheckout: true - Validates connection before use (recommended)
    • testConnectionOnCheckin: false - Skips validation when returning (default)
    • idleConnectionTestPeriod - How often to test idle connections
  • Timeouts:
    • All timeout values are in milliseconds
    • connectionTimeout - Maximum wait for connection (default: 30 seconds)
    • maxConnectionAge - Maximum connection lifetime (default: 3 minutes)
    • maxIdleTime - Maximum idle time before closing (default: 2 minutes)
  • Authentication:
    • useCredentials: true enables username/password authentication
    • useCredentials: false disables authentication (not recommended)
    • Password is stored securely and masked in responses
  • Prepared Statements:
    • maxStatements limits prepared statements per connection
    • Higher values improve performance but use more memory
    • Default: 100 statements per connection
  • Performance Tuning:
    • Increase pool sizes for high-throughput scenarios
    • Adjust timeouts based on network latency
    • Monitor connection pool usage
    • Balance pool size with database server capacity
  • Security:
    • Use strong passwords
    • Use SSL/TLS connections when possible (configure in JDBC URL)
    • Restrict database user permissions
    • Use connection pooling to limit database connections
  • Deployment: Connection changes require deployment to take effect. Set deployToWorker: true or deploy manually.