jdbcdb2zosj9tso

JDBC via BPXBATCH - how to get TSO-user credentials?


I have a little java program that reads a db2 table via jdbc. This program is invoked via "tso bpxbatch myjavatool".

I wonder if there is the possibility to "pass" the username/password of my TSO user to the JDBC driver?

For example, if I connect to DB2 with a simple REXX script I don't have to specify my username/password again and DB2/RACF checks if my user is allowed to execute the SQLs.

Now my java tool is not running in my TSO address space but under the control of the J9 in the USS address space...

Is there also a way to automatically log in to DB2 with the current TSO user?


Solution

  • I don't know too much about BPXBATCH, but I assume you are still running under your own userid in the USS-address-space.

    In your java-code you should be able to get your userid via

    String user = System.getProperty("user.name");
    

    As for the password you could try using RACF-Passtickets instead. There is a library IRRRacf.jar in /user/include/java_classes and the corresponding javadoc in IRRRacfDoc.jar in the same directory. the code for generating the Passticket is rather simple:

    IRRPassTicket generator = new IRRPassTicket();   
    String ptkt = generator.generate(user,applid);
    

    then just pass the passticket instead of the password and you should be fine.

    Alas, there's several aspects you have to make sure of before using this approach: