Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recuperating a database connection 1

Status
Not open for further replies.

chirpyform

Programmer
Jun 20, 2003
202
0
0
FR
In a Java program I connect to a database using jdbc and then I would like to use this connection in the COBOL programms that I run from the same Java program (using micro focus). Is it possible to recuperate a connection in COBOL? Is there an object in COBOL that represents a connection? If there are any experts out there that have any suggestions I would be extremely grateful. The thing is the connection to the database is 15% of the time used in the COBOL programs and we have a less than 1 second delay limit so if we can do 1 connection and pass the connection we would gain lots of time.

Many thanks
Chris
 
Depending on the COBOL vendor you may be able to do it.

Not knowing exactly how JDBC works, I am going to assume some things.

Normally when you connect to a database using an *DBC connection you are assigned a "handle".

This "handle" is the basis for anything you do after this stage, so if you can supply this "handle" to the COBOL program then this should be enough.

E.G. (With Oracle JDBC)
Connection conn = DriverManager.getConnection
("jdbc:eek:racle:eek:ci:mad:(description=(address=(host= myhost)
(protocol=tcp)(port=1521))(connect_data=(INSTANCE_NAME=orcl)))",
"scott", "tiger");

On this situation the handle is "conn".

So when invoking the COBOL program you pass "conn" as a parameter to the program for further use.

I hope someone with experience will be able to help you more than I, but the easiest way of doing it will be by creating a COBOL class if that is not what you are doing already.

The following document my give you some guidance.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
This is pretty much where we got up to. It is the COBOL side that is worrying. We are not using an object oriented version of COBOL and so the idea of a class is not an option. With mfcobol we can use the data type pointer but then I am not sure how to use this. I have tried:
LINKAGE SECTION.
01 CONNECJAVA pointer.
PROCEDURE DIVISION USING CONNECJAVA.
PRINCIPALE SECTION.
EXEC SET CONNECTION ADDRESS OF CONNECJAVA END-EXEC.
or
EXEC SET CONNECTION CONNECJAVA END-EXEC.

any ideas Chris
 
Unless I am wrong you are using OpenESQL contructs. If not then you will not be able to accomplish your request, as you need to be using an ODBC connection within the COBOL program, not just a ESQL one which is database vendor dependent.


If so try the following compiler directive
--------------
CONNECTIONPOOL=[DRIVER | ENVIRONMENT | NONE] Enables use of ODBC 3.0 connection pooling. When a connection is closed, the Driver Manager actually keeps it alive for a timeout period, and saves the overhead of re-establishing a connection from scratch if the application re-opens an identical connection. ODBC allows you to choose between having a pooling for an ODBC environment or for each driver. See your ODBC documentation for details. This option is only useful for applications that frequently open and close connections. Note that some environments, such as Microsoft Transaction Server (MTS) control connection pooling themselves. This option will probably improve the performance of ISAPI applications that are not running under MTS. The default is NONE.
--------------

For what IU have seen so far from the docs you should compile the programs WITHOUT the directive INIT on the sql connection
e.g.
SQL(DBMAN=ODBC,TARGETDB=MSSQLSERVR, DB=datasourcename.db,
PASS=user.pwd,INIT=PROT)
so the COBOL program would remove the last bit (INIT=PROT)

Not sure if this will work with a mix of java/cobol



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top