Guest User

Untitled

a guest
Jun 30th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 2.11 KB | None | 0 0
  1. 000100 IDENTIFICATION DIVISION.
  2. 000200 PROGRAM-ID. usecase2.
  3.        ENVIRONMENT DIVISION.
  4.        
  5.        INPUT-OUTPUT SECTION.
  6.         FILE-CONTROL.
  7.         select parameterfile assign to
  8.          "parbest.txt"
  9.         organization is line sequential
  10.         access mode is sequential.
  11.        
  12.         select logfile assign to
  13.         "logfile.txt"
  14.         organization is sequential
  15.         access mode is sequential.
  16.        
  17.        
  18.        SELECT paper ASSIGN TO PRINTER.
  19.        
  20.        DATA DIVISION.
  21.        FILE SECTION.
  22.        FD paper
  23.         LINAGE IS 60 LINES
  24.         WITH FOOTING AT 56
  25.         LINES AT BOTTOM 3.
  26.        
  27.         FD logfile
  28.         linage 60
  29.         with footing at 56
  30.         lines at bottom 3.    
  31.        01 logMessage pic x(100).
  32.        
  33.        WORKING-STORAGE SECTION.
  34.        EXEC SQL
  35.          BEGIN DECLARE SECTION
  36.        END-EXEC
  37.  
  38.       * SQLCODE is 0 for success, 100 for no data, -1 for failure
  39.        01 SQLCODE PIC S9(3).
  40.  
  41.       * SQLSTATE is a 5 character communication code; 00xxx is success.
  42.        01 SQLSTATE PIC X(5).
  43.  
  44.        01 JdbcString PIC X(255).
  45.        PROCEDURE DIVISION.
  46.        PGM.
  47.        perform DO-CONNECT        
  48.        .
  49.        
  50.        DO-CONNECT.
  51.        STRING "jdbc:sqlserver://localhost\SQLEXPRESS;"
  52.          DELIMITED BY SIZE
  53.          "databaseName=ProjectManagement;"
  54.          DELIMITED BY SIZE
  55.          "userName=Nelis;password=nelis"
  56.          DELIMITED BY SIZE
  57.          INTO JdbcString
  58.        
  59.        EXEC SQL
  60.         CONNECT
  61.           TO :JdbcString        
  62.           DRIVER "com.microsoft.sqlserver.jdbc.SQLServerDriver"                
  63.        END-EXEC.
  64.        
  65.        if SQLCODE = -1
  66.         perform LOG-CONNERR      
  67.         perform STOP-ERR
  68.        end-if.
  69.        
  70.        
  71.        
  72.        
  73.        LOG-CONNERR.
  74.           move "DATABASE: Connection could not be made."
  75.            to logMessage
  76.           write logMessage before advancing 2 lines
  77.        .  
  78.          
  79.        STOP-ERR.
  80.        move "DATABASE: closing the file" to logMessage
  81.        write logMessage
  82.        close paper
  83.        stop run.
Add Comment
Please, Sign In to add comment