Connection Strings
Learn how to connect your applications to VPN Enterprise databases
Retrieve your database connection string using the CLI tool or web dashboard.
# Get connection string for your database
db-cli connection-string my-database
# Get connection string with specific format
db-cli connection-string my-database --format jdbc
# Export to environment file
db-cli connection-string my-database --format env > .env.databaseConnection String Formats
standard Connection
ssl Connection
pool Connection
Database Drivers
Node.js
^8.11.3pg
Python
^2.9.7psycopg2
Java
42.6.0postgresql
C#
7.0.6Npgsql
Go
^1.10.9pq
Ruby
^1.5.4pg
Implementation Examples
// .env file
DATABASE_URL=postgresql://username:password@host:5432/database
// app.js
require('dotenv').config();
const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false
});
module.exports = pool;const pool = require('./db');
async function getUsers() {
try {
const result = await pool.query('SELECT * FROM users');
return result.rows;
} catch (error) {
console.error('Database query error:', error);
throw error;
}
}Security Features
All connections encrypted in transit with TLS 1.3
Automatic SSL certificate management and renewal
Efficient connection reuse and automatic scaling
Built-in pgBouncer for PostgreSQL, ProxySQL for MySQL
Restrict database access to specific IP addresses
Configure allowed IPs in database security settings
Strong password policies and optional 2FA
SCRAM-SHA-256 for PostgreSQL, caching_sha2_password for MySQL
Connection Best Practices
Use Environment Variables
Never hardcode connection strings in your source code
Use .env files and process.env for Node.js applications
Enable SSL/TLS
Always use encrypted connections in production
Add ?sslmode=require to PostgreSQL connection strings
Connection Pooling
Reuse database connections for better performance
Configure pool size based on your application's concurrency needs
Error Handling
Implement proper error handling and retry logic
Use try-catch blocks and exponential backoff for retries
Monitoring
Monitor connection usage and query performance
Set up alerts for connection pool exhaustion and slow queries
Testing Your Connection
Using CLI Tool
# Test database connection
db-cli test-connection my-database
# Test with verbose output
db-cli test-connection my-database --verbose
# Test connection and run sample query
db-cli test-connection my-database --query "SELECT 1"Connection Health Check
# Check database health
db-cli health my-database
# Monitor connection metrics
db-cli metrics my-database --connections
# View connection pool status
db-cli pool-status my-database