Skip to content

feat: Add Account POJO and AccountHandler with JDBC connection and query methods#80

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/java-migration-core
Open

feat: Add Account POJO and AccountHandler with JDBC connection and query methods#80
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/java-migration-core

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 23, 2026

Summary

Adds the Java equivalent of the existing COBOL sql_example.cbl program under a new sql/java/ directory. This is the data-access foundation for the COBOL-to-Java migration of the PostgreSQL account querying program.

Two new files:

  • Account.java — POJO mirroring the COBOL ws-account-record structure (8 fields: id, firstName, lastName, phone, address, isEnabled, createDt, modDt). All-args constructor, getters, toString().
  • AccountHandler.java — JDBC connection manager with query methods that mirror the three COBOL cursors (ACCOUNT-ALL-CUR, ACCOUNT-DISABLED-CUR, ACCOUNT-QUERY-CUR):
    • connect() / disconnect() — lifecycle management
    • getAllAccounts() — all rows ordered by ID
    • getDisabledAccounts() — filtered to IS_ENABLED = 'N'
    • searchAccounts(String) — LIKE search across first name, last name, phone, address
    • displayAccounts(List<Account>) — tabular output matching the COBOL display-account-results paragraph format

All queries use PreparedStatement. Error handling prints SQL state, error code, and message (matching the COBOL check-sql-state pattern). Connection failure calls System.exit(1) to mirror the COBOL stop run behavior.

Both files compile cleanly against JDK 11.

Review & Testing Checklist for Human

  • Verify displayAccounts column widths match the COBOL output format (ID:5, First:8, Last:8, Phone:10, Address:22, Enabled:1). Compare the printf format strings against the COBOL display-account-results paragraph (lines 400-430 of sql_example.cbl).
  • Confirm searchAccounts null-safety — passing null would produce the LIKE pattern %null% (string concatenation). Decide if a null guard is needed or if this is acceptable for the migration scope.
  • Review hardcoded DB credentialsDB_URL, DB_USER, DB_PASSWORD are plaintext constants matching the COBOL connection string. Acceptable for this example/migration repo, but flag if the project intends to externalize config later.
  • End-to-end test: If a PostgreSQL instance is available, run create_test_db.sql, compile both files with the PostgreSQL JDBC driver on the classpath, and write a short main() to call connect()getAllAccounts()displayAccounts()disconnect() to verify output matches the COBOL program.

Notes

  • No Main.java is included — that will be a separate ticket.
  • createDt / modDt are stored as String (matching the COBOL PIC X(20)) rather than java.sql.Timestamp. This is intentional for COBOL parity but could be revisited.
  • Files are in the default package (no package declaration), consistent with the simple example nature of this repo.

Link to Devin session: https://app.devin.ai/sessions/0ebdc63cd333461ca6a0cce03146215a
Requested by: @Colhodm


Open in Devin Review

@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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.

1 participant