Search code examples
javaibm-midrangejtopen

Using JTOpen to read from a data area on an AS400, does the data area object get locked?


Given a DecimalDataArea from JTOpen, when reading and writing to the data area, does the object on the AS400 get locked, preventing simultaneous writes to it from other applications that are on the AS400?

This is the sample code from the javadoc on how to read/write, etc.

// Prepare to work with the system named "My400".
AS400 system = new AS400("My400");

// Create a DecimalDataArea object.
QSYSObjectPathName path = new QSYSObjectPathName("MYLIB", "MYDATA", "DTAARA");
DecimalDataArea dataArea = new DecimalDataArea(system, path.getPath());

// Create the decimal data area on the system using default values.
dataArea.create();

// Clear the data area.
dataArea.clear();

// Write to the data area.
dataArea.write(new BigDecimal("1.2"));

// Read from the data area.
BigDecimal data = dataArea.read();

// Delete the data area from the system.
dataArea.delete();

http://javadoc.midrange.com/jtopen/com/ibm/as400/access/DecimalDataArea.html


Solution

  • No ... the data area operations are atomic, so no locking occurs unless you do it yourself.

    Internally, the implementation actually uses CHGDTAARA to update the data area.

    Wouldn't be a bad enhancement though.