#1
Struts is a reliable Java web framework, and coupling it with Firebird gives you a lightweight yet robust SQL database. With Docker for local development and Kubernetes for production, you can configure your app cleanly—no messy environment switches. Let’s walk through setting up Firebird for Struts in a friendly, approachable way.

1. Add Dependencies in pom.xml

Include the essential libraries for Struts and Firebird connectivity:
<dependencies>
  <!-- Struts web framework -->
  <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>${struts.version}</version>
  </dependency>

  <!-- Firebird JDBC driver (Jaybird) -->
  <dependency>
    <groupId>org.firebirdsql.jdbc</groupId>
    <artifactId>jaybird-full</artifactId>
    <version>${jaybird.version}</version>
  </dependency>

  <!-- Kubernetes client support -->
  <dependency>
    <groupId>io.fabric8</groupId>
    <artifactId>kubernetes-client</artifactId>
    <version>${fabric8.version}</version>
  </dependency>
</dependencies>
This setup prepares Struts to access Firebird via JDBC and enables production-level configuration through Kubernetes.

2. Run Firebird Using Docker for Development

Use the official Firebird image for easy local setup:
docker run -d \
  --name firebird \
  -p 3050:3050 \
  -e ISC_PASSWORD=masterkey \
  firebirdsql/firebird:latest
This container listens on port 3050, with SYSDBA's password set to masterkey. Data persists in the container’s internal storage.

3. Create Dev Configuration: firebird-dev.properties

Add this file under src/main/resources:
db.driver=org.firebirdsql.jdbc.FBDriver
db.url=jdbc:firebirdsql://localhost:3050//firebird/data/yourdb.fdb
db.user=sysdba
db.password=masterkey
db.validationQuery=SELECT 1 FROM RDB$DATABASE
Notice the double slash before the absolute path—that’s required on Unix-based setups. stackoverflow.com In your Struts DAO:
Properties props = new Properties();
props.load(getClass().getResourceAsStream("/firebird-dev.properties"));
Class.forName(props.getProperty("db.driver"));
try (Connection conn = DriverManager.getConnection(
         props.getProperty("db.url"),
         props.getProperty("db.user"),
         props.getProperty("db.password"))) {
  conn.createStatement().executeQuery(props.getProperty("db.validationQuery"));
}
This connects your Struts app to Firebird for development.

4. Prepare Kubernetes Config for Production

In production, use ConfigMaps and Secrets to externalize credentials:
kubectl create configmap firebird-config \
  --from-literal=DB_DRIVER=org.firebirdsql.jdbc.FBDriver \
  --from-literal=DB_URL=jdbc:firebirdsql://firebird-svc:3050//data/proddb.fdb \
  --from-literal=DB_VALIDATION_QUERY=SELECT 1 FROM RDB$DATABASE

kubectl create secret generic firebird-secret \
  --from-literal=DB_USER=sysdba \
  --from-literal=DB_PASSWORD=ProdMasterKey
With secrets and config maps, you avoid hardcoding sensitive data into your app.

5. Create Production Configuration: firebird-prod.properties

Include this file in your resources:
db.driver=${DB_DRIVER}
db.url=${DB_URL}
db.user=${DB_USER}
db.password=${DB_PASSWORD}
db.validationQuery=${DB_VALIDATION_QUERY}
At runtime, Struts picks up these values from the environment—no code changes needed.

6. Kubernetes Deployment Snippet

Update your deployment YAML to inject environment vars:
env:
  - name: DB_DRIVER
    valueFrom:
      configMapKeyRef:
        name: firebird-config
        key: DB_DRIVER
  - name: DB_URL
    valueFrom:
      configMapKeyRef:
        name: firebird-config
        key: DB_URL
  - name: DB_VALIDATION_QUERY
    valueFrom:
      configMapKeyRef:
        name: firebird-config
        key: DB_VALIDATION_QUERY
  - name: DB_USER
    valueFrom:
      secretKeyRef:
        name: firebird-secret
        key: DB_USER
  - name: DB_PASSWORD
    valueFrom:
      secretKeyRef:
        name: firebird-secret
        key: DB_PASSWORD
Ensure your production container has access to the Firebird database service.

7. Add a Struts Health Check Action

Use this snippet to confirm connectivity:
public class DbCheckAction extends ActionSupport {
  public String execute() {
    Properties p = new Properties();
    String filename = System.getenv("DB_URL") != null
        ? "/firebird-prod.properties"
        : "/firebird-dev.properties";
    p.load(getClass().getResourceAsStream(filename));
    Class.forName(p.getProperty("db.driver"));
    try (Connection conn = DriverManager.getConnection(
             p.getProperty("db.url"),
             p.getProperty("db.user"),
             p.getProperty("db.password"));
         Statement stmt = conn.createStatement()) {
      stmt.executeQuery(p.getProperty("db.validationQuery"));
      addActionMessage("Connected to Firebird successfully!");
      return SUCCESS;
    } catch (Exception e) {
      addActionError("Connection failed: " + e.getMessage());
      return ERROR;
    }
  }
}
This action works seamlessly in both dev and production environments.

Why This Setup Works

  • Docker for fast, repeatable dev environments
  • Kubernetes ConfigMaps/Secrets keep production configs secure
  • Consistent codebase—no branching logic, just property swaps
  • Clean separation—dev and prod configs live separately to avoid cross-contamination
With Docker-powered development and secure production deployment via Kubernetes, your Struts app is Firebird-ready with minimal fuss. This setup keeps things clean, safe, and easy to maintain—all without altering your application logic.

image quote pre code