Skip to content

[JDBC] Connectors Forge using Bob - #38

Open
Thomasgloria wants to merge 27 commits into
IBM:mainfrom
Thomasgloria:gt-CF-JDBC
Open

[JDBC] Connectors Forge using Bob#38
Thomasgloria wants to merge 27 commits into
IBM:mainfrom
Thomasgloria:gt-CF-JDBC

Conversation

@Thomasgloria

@Thomasgloria Thomasgloria commented May 4, 2026

Copy link
Copy Markdown

Overview

This PR introduces automated JDBC connector generation capabilities and streamlined AWS deployment for custom JDBC connectors in the CP4D Connector SDK.

What's New

Automated JDBC Connector Generation

Customers can now automatically generate custom JDBC connector code using the Custom JDBC Connector Mode. This eliminates manual configuration and reduces setup time significantly.

Connectors Forge JDBC Mode - Complete Documentation

Table of Contents

  1. Overview
  2. Mode Purpose and Capabilities
  3. Architecture
  4. Deployment Approaches
  5. Complete Workflow
  6. Implementation Details
  7. AWS Deployment Architecture
  8. Configuration Files
  9. Scripts and Automation
  10. Best Practices
  11. Troubleshooting

Overview

The Connectors Forge JDBC mode is an AI-powered assistant that guides users through creating custom JDBC connectors for IBM Cloud Pak for Data (CP4D). It automates the entire process from database information gathering to deployment on multiple platforms (AWS ECS Fargate, OpenShift, or self-hosted servers).

Key Features

  • Two Deployment Modes: Codeless (pre-built image) or Developer (custom code generation)
  • Multi-Platform Deployment: AWS, OpenShift, or self-hosted
  • Automated Driver Management: Automatic download or manual provision of JDBC drivers
  • DSL-Based Configuration: JSON-based Domain Specific Language for connector definition
  • Complete Automation: From DSL creation to production deployment
  • AWS EFS Integration: Persistent driver storage with automatic upload

Mode Purpose and Capabilities

What It Does

The Connectors Forge JDBC mode is a specialized AI assistant that:

  1. Gathers Database Information: Collects JDBC driver details, connection properties, and database-specific features
  2. Creates DSL Configuration: Generates database-specific DSL files from templates
  3. Manages JDBC Drivers: Downloads or copies driver JARs to appropriate locations
  4. Generates Code (Developer mode): Creates complete connector skeleton with customizations
  5. Deploys to Cloud: Automates deployment to AWS ECS Fargate, OpenShift, or self-hosted servers
  6. Handles Infrastructure: Creates EFS, security groups, task definitions, and services

When to Use

Use this mode when you need to:

  • Create a new JDBC connector for any database (MySQL, PostgreSQL, Oracle, SQL Server, etc.)
  • Deploy connectors to AWS ECS Fargate with persistent driver storage
  • Deploy connectors to OpenShift or self-hosted servers
  • Customize existing JDBC connector implementations
  • Set up complete connector infrastructure from scratch

Architecture

High-Level Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Connectors Forge JDBC Mode                    │
│                                                                  │
│  ┌────────────────┐              ┌──────────────────┐          │
│  │  Information   │              │   DSL Creator    │          │
│  │   Gathering    │─────────────▶│   (JSON Config)  │          │
│  └────────────────┘              └──────────────────┘          │
│         │                                 │                     │
│         │                                 │                     │
│         ▼                                 ▼                     │
│  ┌────────────────┐              ┌──────────────────┐          │
│  │ Driver Manager │              │  Code Generator  │          │
│  │ (Download/Copy)│              │  (Developer Mode)│          │
│  └────────────────┘              └──────────────────┘          │
│         │                                 │                     │
│         │                                 │                     │
│         └─────────────┬───────────────────┘                     │
│                       │                                         │
│                       ▼                                         │
│              ┌──────────────────┐                              │
│              │   Deployment     │                              │
│              │   Orchestrator   │                              │
│              └──────────────────┘                              │
│                       │                                         │
│         ┌─────────────┼─────────────┐                          │
│         │             │             │                          │
│         ▼             ▼             ▼                          │
│    ┌────────┐   ┌──────────┐  ┌──────────┐                   │
│    │  AWS   │   │OpenShift │  │Self-Host │                   │
│    │  ECS   │   │          │  │          │                   │
│    └────────┘   └──────────┘  └──────────┘                   │
└─────────────────────────────────────────────────────────────────┘

Component Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         Mode Components                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. Workflow Engine (.bob/rules-create-custom-connector-jdbc/)  │
│     ├── 1_workflow.xml - Complete workflow phases               │
│     ├── 2_best_practices.xml - Best practices and guidelines    │
│     ├── 2_database_information.xml - Database-specific info     │
│     ├── 3_tool_usage_and_best_practices.xml - Tool guidelines   │
│     └── 4_user_interaction.xml - User interaction patterns      │
│                                                                  │
│  2. Configuration Templates (connectors-forge/codeless/jdbc/)   │
│     ├── DSL-jdbc.json - DSL template                            │
│     ├── connector-config.env.template - Connector config        │
│     ├── deploy-container.env.template - Container config        │
│     ├── deploy.env.template - OpenShift deployment config       │
│     └── aws-deployment.properties.template - AWS config         │
│                                                                  │
│  3. Deployment Scripts (connectors-forge/codeless/jdbc/)        │
│     ├── deploy-to-aws.sh - AWS ECS deployment (1074 lines)     │
│     ├── upload-driver-to-efs.sh - EFS driver upload            │
│     ├── deploy-openshift.sh - OpenShift deployment             │
│     ├── deploy-container.sh - Self-hosted deployment           │
│                                                                  │
│  4. Documentation (connectors-forge/codeless/jdbc/)             │
│     ├── AUTOMATIC-DRIVER-UPLOAD.md - Driver upload guide       │
│     ├── EFS-DRIVER-UPLOAD-GUIDE.md - EFS upload details        │
│     ├── UPLOAD-TO-EFS-UI-GUIDE.md - UI-based upload            │
│     └── FIX-EFS-ATTACHMENT.md - Troubleshooting guide          │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Deployment Approaches

1. Codeless Mode (Recommended for Quick Setup)

Overview: Uses pre-built Docker image from GitHub Container Registry

Docker Image: ghcr.io/thomasgloria/wdp-connect-sdk-gen-jdbc-connectors-forge:latest

Benefits:

  • ✅ No code generation required
  • ✅ No build process needed
  • ✅ Faster deployment (minutes vs hours)
  • ✅ Best for standard JDBC use cases
  • ✅ Automatic driver management

Workflow:

1. Information Gathering → 2. DSL Creation → 3. Driver Management → 4. Deployment

Use Cases:

  • Standard database connectors (MySQL, PostgreSQL, etc.)
  • Quick prototyping and testing
  • Production deployments with standard requirements
  • When you don't need custom connector logic

2. Developer Mode (Full Customization)

Overview: Generates complete customizable connector code

Benefits:

  • ✅ Full control over connector implementation
  • ✅ Custom business logic and transformations
  • ✅ Advanced data type mappings
  • ✅ Custom authentication methods
  • ✅ Comprehensive test suite generation

Workflow:

1. Information Gathering → 2. DSL Creation → 3. Code Generation → 
4. Customization → 5. Test Generation → 6. Build → 7. Deployment

Use Cases:

  • Custom JDBC implementations
  • Advanced data transformations
  • Proprietary database connectors
  • When you need to modify connector behavior
  • Enterprise requirements with specific customizations

Complete Workflow

Phase 0: Deployment Approach Selection

Purpose: Choose between Codeless or Developer mode

Steps:

  1. Mode presents deployment options
  2. User selects Codeless or Developer
  3. Mode configures workflow path accordingly

Decision Factors:

  • Codeless: Standard use cases, quick deployment
  • Developer: Custom requirements, full control

Phase 1: Information Gathering

Purpose: Collect database-specific information

Information Collected:

  1. Connector Metadata:

    • Connector name (e.g., mysql, postgresql)
    • Connector label (e.g., "MySQL", "PostgreSQL")
    • Description
  2. JDBC Driver Information:

    • Driver class name (e.g., com.mysql.cj.jdbc.Driver)
    • Maven coordinates (e.g., com.mysql:mysql-connector-j:8.0.33)
    • JDBC URL template (e.g., jdbc:mysql://{host}:{port}/{database})
  3. Database Features:

    • Default port number
    • Schema/catalog support
    • System schemas to exclude
    • Identifier quote character
  4. Driver JAR (Codeless mode only):

    • Automatic download from Maven Central (for open-source drivers)
    • Manual provision (for proprietary drivers like Oracle, DB2)

Supported Databases (with pre-configured information):

  • IBM Db2
  • MySQL
  • PostgreSQL
  • Oracle
  • Microsoft SQL Server
  • MariaDB
  • Snowflake
  • Amazon Redshift
  • Teradata
  • Apache Hive

Phase 2: DSL Creation

Purpose: Generate database-specific DSL configuration file

Process:

  1. Read DSL-jdbc.json template
  2. Populate with database-specific values
  3. Create DSL-jdbc-{connector_name}.json
  4. Remove example/comment fields
  5. Validate JSON structure

DSL File Structure:

{
  "connector_metadata": {
    "connector_name": "mysql",
    "connector_label": "MySQL",
    "connector_description": "JDBC connector for MySQL databases"
  },
  "jdbc_driver": {
    "jdbc_url": "jdbc:mysql://{host}:{port}/{database}",
    "driver_class_name": "com.mysql.cj.jdbc.Driver"
  },
  "connection_properties": {
    "additional_properties": [...]
  },
  "database_specific_features": {
    "supports_schemas": false,
    "supports_catalogs": true,
    "system_schemas": ["information_schema", "mysql", "performance_schema", "sys"]
  },
  "implementation_notes": {
    "dependencies": [{
      "driver_dependencies": ["com.mysql:mysql-connector-j:8.0.33"]
    }]
  }
}

Output: connectors-forge/codeless/jdbc/DSL-jdbc-{connector_name}.json

Phase 2.5: Deployment Preparation (Codeless Mode Only)

Purpose: Prepare configuration files for deployment

Steps:

  1. Select Deployment Type:

    • AWS ECS Fargate
    • OpenShift
    • Self-hosted server
  2. Create connector-config.env:

    • Populated from DSL values
    • Contains connector metadata
    • Includes JDBC driver configuration
  3. Confirm Configuration:

    • Display connector-config.env contents
    • Verify connector label (UI display name)
    • Allow modifications if needed
  4. Create Deployment-Specific Config (if OpenShift):

    • Generate deploy.env from template
    • Configure OpenShift-specific settings
    • Review and update values

connector-config.env Example:

# Connector Configuration
CONNECTOR_DATASOURCE_TYPE=mysql
CONNECTOR_LABEL=MySQL
CONNECTOR_DESCRIPTION=JDBC connector for MySQL databases
JDBC_DRIVER_CLASS=com.mysql.cj.jdbc.Driver
JDBC_DRIVER_PATH=/mnt/efs/driver.jar  # AWS
# JDBC_DRIVER_PATH=/drivers/driver.jar  # OpenShift

Phase 3-9: Developer Mode Only

Phase 3: Label Confirmation
Phase 4: Code Generation (./gradlew generateJavaJdbc)
Phase 5: DSL Relocation
Phase 6: Connector Customization (./gradlew customizeJdbcConnector)
Phase 7: Test Generation (./gradlew generateJdbcTests)
Phase 8: Code Formatting (./gradlew spotlessApply)
Phase 9: Build (./gradlew :jdbc_{name}:build)

Phase 10/11: Deployment

Purpose: Deploy connector to selected platform

AWS ECS Fargate Deployment

Infrastructure Created:

  1. EFS File System: Persistent driver storage
  2. EFS Security Group: NFS access control
  3. EFS Mount Targets: Multi-AZ availability
  4. EFS Access Point: Path isolation
  5. ECS Cluster: Container orchestration
  6. ECS Task Definition: Container configuration with EFS mount
  7. ECS Service: Auto-scaling and load balancing
  8. CloudWatch Logs: Centralized logging

Deployment Process:

cd connectors-forge/codeless/jdbc
./deploy-to-aws.sh

What Happens:

  1. Load configuration from aws-deployment.properties
  2. Validate AWS credentials and parameters
  3. Create VPC resources (if needed)
  4. Create EFS infrastructure
  5. Automatically upload JDBC driver to EFS
  6. Create ECS cluster
  7. Register task definition with EFS mount
  8. Create and start ECS service
  9. Configure CloudWatch logging
  10. Display deployment summary with endpoints

Automatic Driver Upload:

  • Launches temporary EC2 instance
  • Mounts EFS file system
  • Uploads driver.jar via SCP
  • Verifies upload completion
  • Cleans up EC2 instance
  • Total time: ~3-5 minutes

OpenShift Deployment

Process:

cd connectors-forge/codeless/jdbc
./deploy-openshift.sh

Resources Created:

  • Project/Namespace
  • PersistentVolumeClaim (for driver storage)
  • Deployment
  • Service
  • Route (external access)

Self-Hosted Deployment

Process:

cd connectors-forge/codeless/jdbc
./deploy-container.sh

Requirements:

  • Docker installed on target server
  • SSH access configured
  • Driver JAR available locally

Implementation Details

DSL Configuration System

Purpose: Define connector behavior without code

Key Sections:

  1. connector_metadata: Basic connector information
  2. jdbc_driver: Driver class and URL template
  3. connection_properties: Additional connection parameters
  4. authentication: Supported auth methods (basic, Kerberos, OAuth)
  5. database_specific_features: Schema/catalog support, system schemas
  6. data_type_mappings: Custom type conversions
  7. url_template: JDBC URL construction
  8. validation_rules: Property validation logic
  9. custom_actions: Database-specific operations
  10. implementation_notes: Driver dependencies and customization notes

Driver Management

Automatic Download (Codeless Mode)

Supported Databases:

  • MySQL, PostgreSQL, MariaDB (open-source drivers)
  • H2, Derby, SQLite (embedded databases)

Process:

  1. Extract Maven coordinates from DSL
  2. Construct Maven Central URL
  3. Download driver JAR using curl
  4. Save to connectors-forge/codeless/jdbc/driver/driver.jar
  5. Verify file integrity

Maven Central URL Pattern:

https://repo1.maven.org/maven2/{group_path}/{artifact}/{version}/{artifact}-{version}.jar

Manual Provision (Codeless Mode)

Required for:

  • Oracle (proprietary license)
  • IBM Db2 (proprietary license)
  • Microsoft SQL Server (with license)
  • Other proprietary databases

Process:

  1. User provides local path to driver JAR
  2. Mode copies JAR to connectors-forge/codeless/jdbc/driver/driver.jar
  3. Verifies file exists and is readable

Developer Mode

Process:

  1. Add Maven dependency to build.gradle
  2. Gradle downloads driver during build
  3. Driver included in final JAR

AWS Deployment Architecture

Complete Infrastructure Diagram

┌─────────────────────────────────────────────────────────────────────┐
│                            AWS Cloud                                 │
│                                                                      │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │                         VPC                                     │ │
│  │                                                                 │ │
│  │  ┌──────────────────────────────────────────────────────────┐ │ │
│  │  │                    Public Subnet                          │ │ │
│  │  │                                                           │ │ │
│  │  │  ┌─────────────────┐                                     │ │ │
│  │  │  │  NAT Gateway    │                                     │ │ │
│  │  │  └─────────────────┘                                     │ │ │
│  │  └──────────────────────────────────────────────────────────┘ │ │
│  │                           │                                    │ │
│  │  ┌────────────────────────┼─────────────────────────────────┐ │ │
│  │  │                 Private Subnet                            │ │ │
│  │  │                        │                                  │ │ │
│  │  │  ┌─────────────────────▼──────────────────────────────┐  │ │ │
│  │  │  │           ECS Cluster                              │  │ │ │
│  │  │  │                                                    │  │ │ │
│  │  │  │  ┌──────────────────────────────────────────────┐ │  │ │ │
│  │  │  │  │  ECS Service (Fargate)                       │ │  │ │ │
│  │  │  │  │                                              │ │  │ │ │
│  │  │  │  │  ┌────────────────┐  ┌────────────────┐    │ │  │ │ │
│  │  │  │  │  │  Task 1        │  │  Task 2        │    │ │  │ │ │
│  │  │  │  │  │  ┌──────────┐  │  │  ┌──────────┐  │    │ │  │ │ │
│  │  │  │  │  │  │Container │  │  │  │Container │  │    │ │  │ │ │
│  │  │  │  │  │  │          │  │  │  │          │  │    │ │  │ │ │
│  │  │  │  │  │  │/mnt/efs/ │◄─┼──┼──┤/mnt/efs/ │  │    │ │  │ │ │
│  │  │  │  │  │  └──────────┘  │  │  └──────────┘  │    │ │  │ │ │
│  │  │  │  │  └────────────────┘  └────────────────┘    │ │  │ │ │
│  │  │  │  └──────────────────────────────────────────────┘ │  │ │ │
│  │  │  └─────────────────────────────────────────────────────┘  │ │ │
│  │  │                        │                                   │ │ │
│  │  │                        │ EFS Mount (NFS)                   │ │ │
│  │  │                        │                                   │ │ │
│  │  │  ┌─────────────────────▼──────────────────────────────┐   │ │ │
│  │  │  │              AWS EFS File System                    │   │ │ │
│  │  │  │                                                     │   │ │ │
│  │  │  │  /jdbc-drivers/                                    │   │ │ │
│  │  │  │    └── driver.jar  ← Persistent Storage            │   │ │ │
│  │  │  │                                                     │   │ │ │
│  │  │  │  Features:                                          │   │ │ │
│  │  │  │  - Multi-AZ replication                            │   │ │ │
│  │  │  │  - Encryption in transit (TLS)                     │   │ │ │
│  │  │  │  - Access point isolation                          │   │ │ │
│  │  │  └─────────────────────────────────────────────────────┘   │ │ │
│  │  └──────────────────────────────────────────────────────────┘ │ │
│  └────────────────────────────────────────────────────────────────┘ │
│                                                                      │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │                    CloudWatch Logs                              │ │
│  │  /ecs/jdbc-connector                                           │ │
│  │    - Container logs                                            │ │
│  │    - Application logs                                          │ │
│  │    - Error tracking                                            │ │
│  └────────────────────────────────────────────────────────────────┘ │
│                                                                      │
└─────────────────────────────────────────────────────────────────────┘

EFS Driver Upload Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Driver Upload Process                         │
│                                                                  │
│  Step 1: Launch Temporary EC2                                   │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  - Amazon Linux 2023                                        │ │
│  │  - t2.micro instance                                        │ │
│  │  - Same VPC/Subnet as ECS                                   │ │
│  │  - Temporary SSH key pair                                   │ │
│  └────────────────────────────────────────────────────────────┘ │
│                           │                                      │
│                           ▼                                      │
│  Step 2: Mount EFS                                              │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  sudo yum install -y amazon-efs-utils                      │ │
│  │  sudo mkdir -p /mnt/efs                                    │ │
│  │  sudo mount -t efs -o tls fs-xxxxx:/ /mnt/efs             │ │
│  └────────────────────────────────────────────────────────────┘ │
│                           │                                      │
│                           ▼                                      │
│  Step 3: Upload Driver via SCP                                  │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  scp -i key.pem driver.jar ec2-user@instance:/tmp/        │ │
│  │  sudo cp /tmp/driver.jar /mnt/efs/jdbc-drivers/           │ │
│  │  sudo chmod 644 /mnt/efs/jdbc-drivers/driver.jar          │ │
│  └────────────────────────────────────────────────────────────┘ │
│                           │                                      │
│                           ▼                                      │
│  Step 4: Verify and Cleanup                                     │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  - Verify file exists and is readable                      │ │
│  │  - Terminate EC2 instance                                  │ │
│  │  - Delete SSH key pair                                     │ │
│  │  - Remove temporary files                                  │ │
│  └────────────────────────────────────────────────────────────┘ │
│                                                                  │
│  Total Time: ~3-5 minutes                                       │
└─────────────────────────────────────────────────────────────────┘

Security Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      Security Groups                             │
│                                                                  │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  ECS Security Group                                         │ │
│  │  - Outbound: All traffic (for database connections)        │ │
│  │  - Inbound: Port 8080 (from ALB, if configured)           │ │
│  └────────────────────────────────────────────────────────────┘ │
│                           │                                      │
│                           │ Allows NFS (port 2049)              │
│                           ▼                                      │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  EFS Security Group                                         │ │
│  │  - Inbound: Port 2049 from ECS Security Group             │ │
│  │  - Outbound: Not required                                  │ │
│  └────────────────────────────────────────────────────────────┘ │
│                                                                  │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  IAM Roles                                                  │ │
│  │                                                             │ │
│  │  ECS Task Execution Role:                                  │ │
│  │  - Pull images from ECR/GHCR                              │ │
│  │  - Write to CloudWatch Logs                               │ │
│  │  - Access EFS file system                                 │ │
│  │                                                             │ │
│  │  ECS Task Role:                                            │ │
│  │  - Application-specific permissions                        │ │
│  │  - Database connection credentials (via Secrets Manager)   │ │
│  └────────────────────────────────────────────────────────────┘ │
│                                                                  │
│  ┌────────────────────────────────────────────────────────────┐ │
│  │  Encryption                                                 │ │
│  │  - EFS: Encryption in transit (TLS)                       │ │
│  │  - EFS: Encryption at rest (optional)                     │ │
│  │  - CloudWatch Logs: Encrypted                             │ │
│  └────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Configuration Files

1. DSL-jdbc-{connector_name}.json

Location: connectors-forge/codeless/jdbc/

Purpose: Define connector behavior and database-specific features

Key Sections:

  • Connector metadata (name, label, description)
  • JDBC driver configuration
  • Connection properties
  • Authentication methods
  • Database-specific features
  • Data type mappings
  • Driver dependencies

2. connector-config.env

Location: connectors-forge/codeless/jdbc/

Purpose: Runtime connector configuration

Key Variables:

CONNECTOR_DATASOURCE_TYPE=mysql
CONNECTOR_LABEL=MySQL
CONNECTOR_DESCRIPTION=JDBC connector for MySQL databases
JDBC_DRIVER_CLASS=com.mysql.cj.jdbc.Driver
JDBC_DRIVER_PATH=/mnt/efs/driver.jar

3. aws-deployment.properties

Location: connectors-forge/codeless/jdbc/

Purpose: AWS infrastructure configuration

Key Properties:

# AWS Configuration
AWS_ACCOUNT_ID=123456789012
AWS_REGION=us-west-1

# VPC Configuration
VPC_ID=vpc-xxxxx
SUBNET_ID=subnet-xxxxx

# ECS Configuration
CLUSTER_NAME=jdbc-connector-cluster
SERVICE_NAME=jdbc-connector-service
TASK_FAMILY=jdbc-connector

# EFS Configuration
ENABLE_EFS=true
EFS_NAME=jdbc-connector-efs

# Container Configuration
DOCKER_IMAGE=ghcr.io/thomasgloria/wdp-connect-sdk-gen-jdbc-connectors-forge:latest
CONTAINER_PORT=8080
DESIRED_COUNT=1
CPU=256
MEMORY=512

4. deploy.env (OpenShift)

Location: connectors-forge/codeless/jdbc/

Purpose: OpenShift deployment configuration

Key Variables:

OPENSHIFT_PROJECT=jdbc-connectors
OPENSHIFT_REGISTRY=image-registry.openshift-image-registry.svc:5000
IMAGE_NAME=jdbc-connector
IMAGE_TAG=latest
REPLICAS=1
MEMORY_LIMIT=512Mi
CPU_LIMIT=500m

5. deploy-container.env

Location: connectors-forge/codeless/jdbc/

Purpose: Self-hosted deployment configuration

Key Variables:

SSH_HOST=your-server.com
SSH_USER=deploy
SSH_PORT=22
CONTAINER_NAME=jdbc-connector
HOST_PORT=8080
CONTAINER_PORT=8080

Scripts and Automation

1. deploy-to-aws.sh

Purpose: Complete AWS ECS Fargate deployment automation

Size: 1074 lines

Key Functions:

# Load and validate configuration
load_properties()
validate_parameters()

# VPC and networking
create_vpc_resources()
create_security_groups()

# EFS infrastructure
create_efs_filesystem()
create_efs_mount_targets()
create_efs_access_point()

# Driver upload (automatic)
upload_driver_to_efs()

# ECS deployment
create_ecs_cluster()
register_task_definition()
create_ecs_service()

# Monitoring
setup_cloudwatch_logs()

# Cleanup
cleanup_on_error()

Usage:

cd connectors-forge/codeless/jdbc
./deploy-to-aws.sh [path-to-properties-file]

Features:

  • ✅ Complete infrastructure automation
  • ✅ Automatic driver upload to EFS
  • ✅ Error handling and rollback
  • ✅ Progress tracking with colored output
  • ✅ Deployment summary with endpoints
  • ✅ CloudWatch Logs integration

2. upload-driver-to-efs.sh

Purpose: Upload JDBC driver to EFS via temporary EC2

Key Functions:

# Setup
create_key_pair()
launch_ec2_instance()
wait_for_instance()

# Upload
mount_efs_on_ec2()
upload_driver_via_scp()
verify_upload()

# Cleanup
terminate_ec2_instance()
delete_key_pair()

Usage:

cd connectors-forge/codeless/jdbc
./upload-driver-to-efs.sh [path-to-properties-file]

Process:

  1. Creates temporary SSH key pair
  2. Launches t2.micro EC2 instance
  3. Installs amazon-efs-utils
  4. Mounts EFS file system
  5. Uploads driver via SCP
  6. Verifies upload
  7. Cleans up all resources

Time: ~3-5 minutes

3. deploy-openshift.sh

Purpose: Deploy connector to OpenShift

Features:

  • Creates OpenShift project
  • Builds container image
  • Creates PVC for driver storage
  • Deploys application
  • Exposes route

4. deploy-container.sh

Purpose: Deploy to self-hosted server via SSH

Features:

  • SSH-based deployment
  • Docker container management
  • Volume mounting for drivers
  • Port mapping configuration

Best Practices

DSL Configuration

  1. Research Database Documentation

    • Verify JDBC driver class name from official docs
    • Check default port numbers and URL patterns
    • Understand schema vs catalog support
    • Identify system schemas to exclude
  2. Use Descriptive Names

    • Good: jdbc_mysql, jdbc_postgres
    • Bad: mydb, JDBC_MySQL
  3. Remove Example Fields

    • Clean up all _example, _comment, _note fields
    • Keep only production-ready configuration
  4. Specify Complete URL Templates

    • Use {placeholder} syntax for connection properties
    • Include all required parameters
    • Test URL format with actual values

Driver Management

  1. Automatic Download (when possible)

    • Preferred for open-source drivers
    • Faster setup
    • Consistent versions
  2. Manual Provision (when required)

    • For proprietary drivers (Oracle, DB2)
    • Verify driver compatibility
    • Check license requirements
  3. Version Control

    • Document driver versions in DSL
    • Test with specific driver versions
    • Update drivers carefully

AWS Deployment

  1. Use Private Subnets

    • Deploy ECS tasks in private subnets
    • Use NAT Gateway for outbound connectivity
    • Restrict security group rules
  2. Enable EFS Encryption

    • Encryption in transit (TLS) - enabled by default
    • Encryption at rest (optional)
    • Use KMS keys for sensitive data
  3. Monitor with CloudWatch

    • Enable container insights
    • Set up log retention policies
    • Create alarms for errors
  4. Cost Optimization

    • Use Fargate Spot for non-production
    • Right-size CPU and memory
    • Clean up unused resources

Security

  1. Credentials Management

    • Never commit credentials to version control
    • Use AWS Secrets Manager for database passwords
    • Rotate credentials regularly
  2. Network Security

    • Use security groups effectively
    • Restrict EFS access to ECS security group only
    • Enable VPC Flow Logs
  3. IAM Permissions

    • Follow principle of least privilege
    • Use separate roles for task execution and task
    • Audit IAM policies regularly

Troubleshooting

Common Issues

1. Driver Not Found in Container

Symptoms:

  • ClassNotFoundException for JDBC driver
  • Container logs show driver loading errors

Solutions:

# Verify driver exists in EFS
./verify-efs-driver.sh

# Check EFS mount in task definition
aws ecs describe-task-definition --task-definition jdbc-connector

# Verify JDBC_DRIVER_PATH in connector-config.env
cat connector-config.env | grep JDBC_DRIVER_PATH

# Re-upload driver if needed
./upload-driver-to-efs.sh

2. EFS Mount Timeout

Symptoms:

  • Task fails to start
  • Logs show "mount.nfs: Connection timed out"

Solutions:

# Check security group rules
./verify-efs-sg.sh

# Verify EFS and ECS are in same VPC
aws efs describe-file-systems --file-system-id fs-xxxxx
aws ecs describe-clusters --clusters jdbc-connector-cluster

# Check mount targets
aws efs describe-mount-targets --file-system-id fs-xxxxx

3. Permission Denied on EFS

Symptoms:

  • Container can't read driver.jar
  • Permission errors in logs

Solutions:

# Fix permissions via temporary EC2
# Launch EC2, mount EFS, then:
sudo chmod 644 /mnt/efs/jdbc-drivers/driver.jar
sudo chown 1000:1000 /mnt/efs/jdbc-drivers/driver.jar

4. Task Definition Registration Fails

Symptoms:

  • deploy-to-aws.sh fails during task definition registration
  • Invalid parameter errors

Solutions:

# Validate aws-deployment.properties
cat aws-deployment.properties

# Check EFS file system ID
aws efs describe-file-systems --query 'FileSystems[?Name==`jdbc-connector-efs`]'

# Verify IAM role exists
aws iam get-role --role-name ecsTaskExecutionRole

5. Container Fails to Start

Symptoms:

  • Service shows tasks starting and stopping repeatedly
  • CloudWatch Logs show errors

Solutions:

# Check CloudWatch Logs
aws logs tail /ecs/jdbc-connector --follow

# Describe failed tasks
aws ecs describe-tasks --cluster jdbc-connector-cluster --tasks <task-id>

# Verify environment variables
aws ecs describe-task-definition --task-definition jdbc-connector \
  --query 'taskDefinition.containerDefinitions[0].environment'

# Check connector-config.env values
cat connector-config.env

Debugging Commands

# Get shell access to running container
./exec-into-container.sh

# Inside container, verify driver
ls -lh /mnt/efs/jdbc-drivers/
cat /mnt/efs/jdbc-drivers/driver.jar | head -c 100

# Check environment variables
env | grep JDBC
env | grep CONNECTOR

# Test JDBC connection (if tools available)
java -cp /mnt/efs/jdbc-drivers/driver.jar:. TestConnection

Log Analysis

CloudWatch Logs Location: /ecs/jdbc-connector

Key Log Patterns:

# Driver loading
"Loading JDBC driver: com.mysql.cj.jdbc.Driver"
"Driver loaded successfully"

# EFS mount
"Mounting EFS volume at /mnt/efs"
"EFS mount successful"

# Connection errors
"java.sql.SQLException: No suitable driver found"
"ClassNotFoundException: com.mysql.cj.jdbc.Driver"
"Connection refused"

Getting Help

  1. Check Documentation:

    • EFS-DRIVER-UPLOAD-GUIDE.md
    • AUTOMATIC-DRIVER-UPLOAD.md
    • FIX-EFS-ATTACHMENT.md
  2. Verify Configuration:

    • Run verification scripts
    • Check all .env and .properties files
    • Validate DSL file structure
  3. Review Logs:

    • CloudWatch Logs for container output
    • AWS CloudTrail for API calls
    • VPC Flow Logs for network issues

Summary

The Connectors Forge JDBC mode is a comprehensive solution for creating and deploying JDBC connectors to Cloud Pak for Data. It provides:

Key Capabilities

  • Two Deployment Modes: Codeless (quick) or Developer (customizable)
  • Multi-Platform Support: AWS, OpenShift, self-hosted
  • Automated Infrastructure: Complete AWS ECS + EFS setup
  • Driver Management: Automatic download or manual provision
  • Persistent Storage: EFS-based driver storage with automatic upload
  • Production-Ready: Security, monitoring, and best practices built-in

Workflow Summary

1. Select Mode (Codeless/Developer)
2. Gather Database Information
3. Create DSL Configuration
4. Manage JDBC Driver
5. Prepare Deployment Configuration
6. Deploy to Platform (AWS/OpenShift/Self-hosted)
7. Verify and Monitor

Architecture Highlights

  • AWS ECS Fargate: Serverless container deployment
  • AWS EFS: Persistent, shared driver storage
  • Automatic Upload: Driver uploaded via temporary EC2
  • Security: VPC isolation, security groups, IAM roles
  • Monitoring: CloudWatch Logs and metrics

Files and Scripts

  • Configuration: DSL, connector-config.env, aws-deployment.properties
  • Deployment: deploy-to-aws.sh (1074 lines), upload-driver-to-efs.sh

The mode handles the complete lifecycle from database information gathering to production deployment, with comprehensive automation, error handling, and best practices built-in.


Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Signed-off-by: Gloria Thomas <Gloria.Thomas1@ibm.com>
Thomasgloria and others added 10 commits June 13, 2026 18:42
…tors

- Add deploy-openshift.sh script with full deployment orchestration
- Add OpenShift resource templates (deployment, service, route, PVC, project)
- Add deploy.env.template for OpenShift configuration
- Rename connector-config.properties.template to connector-config.env.template
- Support pre-built image deployment with driver PVC mounting
- Include namespace creation, ConfigMap setup, and deployment verification
@Thomasgloria Thomasgloria changed the title [JDBC] Connector code generation using Bob [JDBC] Connectors Forge using Bob Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants