A cutting-edge project for the Database Connectivity and Access course. Because nothing says "modern" like COBOL and IBM Db2.
- COBOL - A language from 1959 that refuses to die
- IBM Db2 - Because Oracle was too mainstream
- Docker - The only thing here invented this century
- GixSQL - An ESQL preprocessor nobody's heard of, connecting technologies that shouldn't talk to each other
docker compose up -d
# Wait 15 minutes (most likely even more) for Db2 to remember how to start and for dependencies to compile.
docker logs cobol-app
Connects to a database. Fetches 5 employees. Prints them. Revolutionary.
Firstly, the plan was to use the Ocesql precompiler to fetch the data. After about half an hour of debugging, I noticed that it said:
Ocesql currently supports PostgreSQL database only.
So, I had two options:
- Use PostgreSQL (that would be too boring).
- Find another method of connecting to Db2, preferably via ODBC.
After spending a few more minutes on GitHub, I found the GixSQL project that allows GnuCOBOL to run with PostgreSQL, MySQL, Oracle, and SQLite, but it also mentioned ODBC.
Digging a little bit more, messing with libraries in the application's Dockerfile, I finally managed to compile GixSQL and its dependencies. Using Docker's layered caching for Dockerfiles, I could just use
docker compose up -d
docker compose logs cobol-appto recompile the COBOL project only after the first build and make everything work.
The COBOL application is going to wait for Db2 to initialize before it fetches the data (accomplished with the depends_on directive in docker-compose.yml).
This project was designed to meet the course requirement of using a non-Java language and a non-MySQL database. So, like any other sane person would do, I decided to choose COBOL and IBM Db2.