feat: Add Java equivalent of COBOL SQL example program (PostgreSQL account handler)#81
Open
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Open
Conversation
Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
- Add Account.java POJO with fields: id, firstName, lastName, phone, address, isEnabled, createDt, modDt - Add AccountHandler.java JDBC handler with connect/disconnect, getAllAccounts, getDisabledAccounts, searchAccounts, displayAccounts - Add Main.java with interactive console menu replicating COBOL program's menu-driven interface - Display all accounts - Display disabled accounts - Query/search accounts with repeat search loop - Exit with graceful disconnect Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Author
End-to-End Test ResultsRan the Java program locally against PostgreSQL 14 with 11-row test dataset. All menu options exercised. All 9 tests passed
Full output |
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a complete Java port of the existing COBOL SQL example program (
sql/sql_example.cbl) under a newsql/java/directory. The Java version provides identical functionality — connecting to thecobol_db_examplePostgreSQL database and offering an interactive console menu to display all accounts, display disabled accounts, and search accounts by name/phone/address.New files:
Account.java— POJO mirroring the COBOLws-account-recordstructure (8 fields)AccountHandler.java— JDBC connection lifecycle + three query methods mirroring the COBOL cursors (ACCOUNT-ALL-CUR,ACCOUNT-DISABLED-CUR,ACCOUNT-QUERY-CUR), plus tabular display outputMain.java— Interactive menu loop replicating the COBOLmain-procedure(menu selection, search-again sub-loop, connect-on-start / disconnect-on-exit)sql/java/README.md— Prerequisites, compile/run instructions, connection configUpdated:
sql/README.md— added cross-reference to the new Java implementation.All queries use
PreparedStatement. Error handling prints SQL state/code/message matching the COBOLcheck-sql-statepattern. Connection failure callsSystem.exit(1)mirroring the COBOLstop run.Review & Testing Checklist for Human
create_test_db.sql, compile with the JDBC driver on classpath (javac -cp .:postgresql-*.jar *.java), then runjava -cp .:postgresql-*.jar Mainand exercise all 4 menu options. Verify output matches the COBOL program.displayAccountscolumn widths against the COBOLdisplay-account-resultsparagraph (lines 400–430 ofsql_example.cbl). Theprintfformat strings should produce aligned columns matching the COBOL fixed-width output.sql_example.cbl) — same columns, sameORDER BY, sameWHEREclauses.searchAccounts(null)produces"%null%"rather than throwing — acceptable for this demo scope, but confirm this is fine.Notes
createDt/modDtare stored asString(matching COBOLPIC X(20)) rather thanjava.sql.Timestamp. Intentional for COBOL parity; display format depends on the JDBC driver's default timestamp-to-string conversion.packagedeclaration), consistent with the simple example nature of the repo.Link to Devin session: https://app.devin.ai/sessions/2391de1faa624377bb458732ddb38350
Requested by: @Colhodm