Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 000100 IDENTIFICATION DIVISION.
- 000200 PROGRAM-ID. usecase2.
- ENVIRONMENT DIVISION.
- INPUT-OUTPUT SECTION.
- FILE-CONTROL.
- select parameterfile assign to
- "parbest.txt"
- organization is line sequential
- access mode is sequential.
- select logfile assign to
- "logfile.txt"
- organization is sequential
- access mode is sequential.
- SELECT paper ASSIGN TO PRINTER.
- DATA DIVISION.
- FILE SECTION.
- FD paper
- LINAGE IS 60 LINES
- WITH FOOTING AT 56
- LINES AT BOTTOM 3.
- FD logfile
- linage 60
- with footing at 56
- lines at bottom 3.
- 01 logMessage pic x(100).
- WORKING-STORAGE SECTION.
- EXEC SQL
- BEGIN DECLARE SECTION
- END-EXEC
- * SQLCODE is 0 for success, 100 for no data, -1 for failure
- 01 SQLCODE PIC S9(3).
- * SQLSTATE is a 5 character communication code; 00xxx is success.
- 01 SQLSTATE PIC X(5).
- 01 JdbcString PIC X(255).
- PROCEDURE DIVISION.
- PGM.
- perform DO-CONNECT
- .
- DO-CONNECT.
- STRING "jdbc:sqlserver://localhost\SQLEXPRESS;"
- DELIMITED BY SIZE
- "databaseName=ProjectManagement;"
- DELIMITED BY SIZE
- "userName=Nelis;password=nelis"
- DELIMITED BY SIZE
- INTO JdbcString
- EXEC SQL
- CONNECT
- TO :JdbcString
- DRIVER "com.microsoft.sqlserver.jdbc.SQLServerDriver"
- END-EXEC.
- if SQLCODE = -1
- perform LOG-CONNERR
- perform STOP-ERR
- end-if.
- LOG-CONNERR.
- move "DATABASE: Connection could not be made."
- to logMessage
- write logMessage before advancing 2 lines
- .
- STOP-ERR.
- move "DATABASE: closing the file" to logMessage
- write logMessage
- close paper
- stop run.
Add Comment
Please, Sign In to add comment