Guest User

Untitled

a guest
Jun 27th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.77 KB | None | 0 0
  1. IDENTIFICATION DIVISION.
  2. PROGRAM-ID. dbConn.
  3.  
  4. DATA DIVISION.
  5. WORKING-STORAGE SECTION.
  6. EXEC SQL BEGIN DECLARE SECTION END-EXEC
  7.  
  8. * SQLCODE is 0 for success, 100 for no data, -1 for failure
  9. 77 SQLCODE PIC S9(3).
  10.  
  11. * SQLSTATE is a 5 character communication code; 00xxx is success.
  12. 77 SQLSTATE PIC X(5).
  13.  
  14. EXEC SQL END DECLARE SECTION END-EXEC
  15.  
  16. PROCEDURE DIVISION.
  17. MAIN-PARAGRAPH.
  18. * Initial code
  19.     PERFORM DO-CONNECT
  20.         DISPLAY "SQLCODE= " + SQLCODE.
  21.         DISPLAY "SQLSTATE= " + SQLSTATE
  22.         DISPLAY lijn
  23. * Use the database      
  24.  
  25.     PERFORM DO-DISCONNECT
  26.     ACCEPT SQLSTATE
  27. * Terminate the program    
  28.     GOBACK
  29.  
  30. * The SQL connect statement must be completed with the information
  31. * appropriate to the actual JDBC driver in use.  JDBC stands for
  32. * Java DataBase Connectivity, and it is the method by which PERCobol
  33. * accesses databases and database-like data sources.
  34. *
  35. * The JDBC driver itself must be included in the Java library path
  36. * in order to successfully connect to the database.  The JDBC driver
  37. * is generally included with the database itself; see the database
  38. * documentation for more details.
  39. *
  40. * When connecting to a datasource, the jdbc:url may be
  41. * ds:data-source-name.
  42. *
  43. * jdbc:url      The JDBC url to the database itself
  44. * user          Usually USER     :cobol-variable-name
  45. * password      Usually PASSWORD :cobol-variable-name
  46. * com.driver.name   This is the classname of the driver
  47. *
  48. DO-CONNECT.
  49.     EXEC SQL
  50.         CONNECT
  51.             TO "jdbc:mysql://localhost/naamdb"
  52.             USER "root"
  53.             DRIVER "com.mysql.jdbc.Driver"
  54.     END-EXEC
  55.  
  56. * Disconnect from the SQL database connection.  This allows the
  57. * JDBC driver to free any resources required for the connection.
  58.  
  59. DO-DISCONNECT.
  60.     EXEC SQL
  61.         DISCONNECT
  62.     END-EXEC
Add Comment
Please, Sign In to add comment