February 16th, 2013, 04:24 PM
Join Date: Feb 2013
Time spent in forums: 1 h 19 m 53 sec
Reputation Power: 0
Other Language - [COBOL] Can't execute SQL query
I'm new on this forum and I joined because I have a question about COBOL, I'm making a school project and we have to connect to an SQL-based database (I'm using MySQL). My program can connect to the database but it doesn't want to execute the SQL query I entered, although I do exactly the same as they do on multiple websites.
I want to insert a new row into a table called jonathan in the database called jojo. The login is working since I get SQLCODE 0 & SQLSTATE 00000.
This is my code:
DATA DIVISION. WORKING-STORAGE SECTION.
01 name PIC X(5).
01 idcode PIC 9(2).
01 city PIC X(200).
BEGIN DECLARE SECTION
* 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).
END DECLARE SECTION
* Initial code
DISPLAY "After connecting to the database:"
DISPLAY "SQLCODE= " + SQLCODE.
DISPLAY "SQLSTATE= " + SQLSTATE
MOVE "Jonathann" TO name
MOVE 28 TO idcode
MOVE "GENT" TO city
* Use the database
INSERT INTO jonathan (name, idcode, city)
VALUES (:name, :idcode, :city)
* Terminate the program
* The SQL connect statement must be completed with the information
* appropriate to the actual JDBC driver in use. JDBC stands for
* Java DataBase Connectivity, and it is the method by which PERCobol
* accesses databases and database-like data sources.
* The JDBC driver itself must be included in the Java library path
* in order to successfully connect to the database. The JDBC driver
* is generally included with the database itself; see the database
* documentation for more details. *
* When connecting to a datasource, the jdbc:url may be
* jdbc:url The JDBC url to the database itself
* com.driver.name This is the classname of the driver
DELIMITED BY SIZE
DELIMITED BY SIZE
* DRIVER "com.microsoft.sqlserver.jdbc.SQLServerDriver"
* Disconnect from the SQL database connection. This allows the
* JDBC driver to free any resources required for the connection.
Thanks in advance.