com.ibm.jtopenlite.ddm

Class DDMConnection

  • All Implemented Interfaces:
    Connection


    public class DDMConnection
    extends HostServerConnection
    Represents a TCP/IP socket connection to the System i Distributed Data Management (DDM) host server (QUSRWRK/QRWTSRVR job). See DDMRead for an example of using DDM.
    • Field Detail

      • DEFAULT_DDM_SERVER_PORT

        public static final int DEFAULT_DDM_SERVER_PORT
        See Also:
        Constant Field Values
      • DEFAULT_SSL_DDM_SERVER_PORT

        public static final int DEFAULT_SSL_DDM_SERVER_PORT
        See Also:
        Constant Field Values
    >
    • Method Detail

      • sendEndJobRequest

        protected void sendEndJobRequest()
                                  throws java.io.IOException
        No-op. The DDM host server does not use an end job datastream.
        Specified by:
        sendEndJobRequest in class HostServerConnection
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(java.lang.String system,
                                  java.lang.String user,
                                  java.lang.String password)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(boolean isSSL,
                                  java.lang.String system,
                                  java.lang.String user,
                                  java.lang.String password)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(SystemInfo info,
                                  java.lang.String user,
                                  java.lang.String password)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(boolean isSSL,
                                  SystemInfo info,
                                  java.lang.String user,
                                  java.lang.String password)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(SystemInfo info,
                                  java.lang.String user,
                                  java.lang.String password,
                                  int ddmPort)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and port, and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • getConnection

        public static DDMConnection getConnection(boolean isSSL,
                                  SystemInfo info,
                                  java.lang.String user,
                                  java.lang.String password,
                                  int ddmPort)
                                           throws java.io.IOException
        Establishes a new socket connection to the specified system and port, and authenticates the specified user and password.
        Throws:
        java.io.IOException
      • close

        public Message[] close(DDMFile file)
                        throws java.io.IOException
        Closes the specified file and returns any messages that were issued.
        Throws:
        java.io.IOException
      • closeReturnMessageList

        public java.util.List<Message> closeReturnMessageList(DDMFile file)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • open

        public DDMFile open(java.lang.String library,
                   java.lang.String file,
                   java.lang.String member,
                   java.lang.String recordFormat)
                     throws java.io.IOException
        Opens the specified file for sequential read-only access and a preferred batch size of 100.
        Parameters:
        library - The name of the library in which the file resides. For example, "QSYS".
        file - The name of the physical or logical file.
        member - The member within the file. This can be a special value such as "*FIRST".
        recordFormat - The name of the record format. This value can also be obtained from DDMRecordFormat.getName().
        Throws:
        java.io.IOException
      • open

        public DDMFile open(java.lang.String library,
                   java.lang.String file,
                   java.lang.String member,
                   java.lang.String recordFormat,
                   int readWriteType,
                   boolean keyed,
                   int preferredBatchSize,
                   int numBuffers)
                     throws java.io.IOException
        Opens the specified file for reading or writing records.
        Parameters:
        library - The name of the library in which the file resides. For example, "QSYS".
        file - The name of the physical or logical file.
        member - The member within the file. This can be a special value such as "*FIRST".
        recordFormat - The name of the record format. This value can also be obtained from DDMRecordFormat.getName().
        readWriteType - The read-write access type to use. Allowed values are:
        keyed - Indicates if the file should be opened for sequential or keyed access.
        preferredBatchSize - The number of records to read or write at a time. This is a preferred number because the DDMConnection may decide to use a different batch size depending on circumstances (e.g. READ_WRITE files always use a batch size of 1).
        numBuffers - The number of data buffers to allocate for use when reading new records. The DDMConnection will round-robin through the data buffers as it calls DDMReadCallback.newRecord(). This can be useful for multi-threaded readers that process new record data, such as DDMThreadedReader. In such cases, each processing thread could be assigned a specific data buffer, to avoid contention. See DDMDataBuffer.
        Throws:
        java.io.IOException
      • getFileMemberDescriptions

        public java.util.List<DDMFileMemberDescription> getFileMemberDescriptions(java.lang.String library,
                                                                         java.lang.String file)
                                                                           throws java.io.IOException
        Retrieves the member descriptions for the specified file.
        Throws:
        java.io.IOException
      • getFileMemberDescriptions

        public java.util.List<DDMFileMemberDescription> getFileMemberDescriptions(DDMFile file)
                                                                           throws java.io.IOException
        Retrieves the member descriptions for the specified file.
        Throws:
        java.io.IOException
      • getRecordFormat

        public DDMRecordFormat getRecordFormat(java.lang.String library,
                                      java.lang.String file)
                                        throws java.io.IOException
        Retrieves the record format of the specified file. This currently only retrieves the first record format in a multi-format file.
        Throws:
        java.io.IOException
      • getRecordFormat

        public DDMRecordFormat getRecordFormat(DDMFile file)
                                        throws java.io.IOException
        Retrieves the record format of the specified file. This currently only retrieves the first record format in a multi-format file.
        Throws:
        java.io.IOException
      • read

        public void read(DDMFile file,
                DDMReadCallback listener,
                int recordNumber)
                  throws java.io.IOException
        Reads the record with the specified record number from the file.
        Throws:
        java.io.IOException
      • readKeyEqual

        public void readKeyEqual(DDMFile file,
                        DDMReadCallback listener,
                        byte[] key,
                        int numberOfKeyFields)
                          throws java.io.IOException
        Reads the next record whose key is equal to the specified key.
        Throws:
        java.io.IOException
      • readKeyGreater

        public void readKeyGreater(DDMFile file,
                          DDMReadCallback listener,
                          byte[] key,
                          int numberOfKeyFields)
                            throws java.io.IOException
        Reads the next record whose key is greater than the specified key.
        Throws:
        java.io.IOException
      • readKeyGreaterOrEqual

        public void readKeyGreaterOrEqual(DDMFile file,
                                 DDMReadCallback listener,
                                 byte[] key,
                                 int numberOfKeyFields)
                                   throws java.io.IOException
        Reads the next record whose key is greater than or equal to the specified key.
        Throws:
        java.io.IOException
      • readKeyLess

        public void readKeyLess(DDMFile file,
                       DDMReadCallback listener,
                       byte[] key,
                       int numberOfKeyFields)
                         throws java.io.IOException
        Reads the next record whose key is less than the specified key.
        Throws:
        java.io.IOException
      • readKeyLessOrEqual

        public void readKeyLessOrEqual(DDMFile file,
                              DDMReadCallback listener,
                              byte[] key,
                              int numberOfKeyFields)
                                throws java.io.IOException
        Reads the next record whose key is less than or equal to the specified key.
        Throws:
        java.io.IOException
      • positionToKeyEqual

        public void positionToKeyEqual(DDMFile file,
                              DDMReadCallback listener,
                              byte[] key,
                              int numberOfKeyFields)
                                throws java.io.IOException
        Positions the file cursor to the record whose key is equal to the specified key.
        Throws:
        java.io.IOException
      • positionToKeyGreater

        public void positionToKeyGreater(DDMFile file,
                                DDMReadCallback listener,
                                byte[] key,
                                int numberOfKeyFields)
                                  throws java.io.IOException
        Positions the file cursor to the record whose key is greater than the specified key.
        Throws:
        java.io.IOException
      • positionToKeyGreaterOrEqual

        public void positionToKeyGreaterOrEqual(DDMFile file,
                                       DDMReadCallback listener,
                                       byte[] key,
                                       int numberOfKeyFields)
                                         throws java.io.IOException
        Positions the file cursor to the record whose key is greater than or equal to the specified key.
        Throws:
        java.io.IOException
      • positionToKeyLess

        public void positionToKeyLess(DDMFile file,
                             DDMReadCallback listener,
                             byte[] key,
                             int numberOfKeyFields)
                               throws java.io.IOException
        Positions the file cursor to the record whose key is less than the specified key.
        Throws:
        java.io.IOException
      • positionToKeyLessOrEqual

        public void positionToKeyLessOrEqual(DDMFile file,
                                    DDMReadCallback listener,
                                    byte[] key,
                                    int numberOfKeyFields)
                                      throws java.io.IOException
        Positions the file cursor to the record whose key is less than or equal to the specified key.
        Throws:
        java.io.IOException
      • readNext

        public void readNext(DDMFile file,
                    DDMReadCallback listener)
                      throws java.io.IOException
        Reads the next record from the specified file and positions the cursor on or after it.
        Throws:
        java.io.IOException
      • readPrevious

        public void readPrevious(DDMFile file,
                        DDMReadCallback listener)
                          throws java.io.IOException
        Reads the previous record from the specified file and positions the cursor on or before it.
        Throws:
        java.io.IOException
      • readFirst

        public void readFirst(DDMFile file,
                     DDMReadCallback listener)
                       throws java.io.IOException
        Reads the first record from the specified file and positions the cursor on or after it.
        Throws:
        java.io.IOException
      • readLast

        public void readLast(DDMFile file,
                    DDMReadCallback listener)
                      throws java.io.IOException
        Reads the last record from the specified file and positions the cursor on or after it.
        Throws:
        java.io.IOException
      • readCurrent

        public void readCurrent(DDMFile file,
                       DDMReadCallback listener)
                         throws java.io.IOException
        Reads the current record from the specified file and positions the cursor on or after it.
        Throws:
        java.io.IOException
      • positionToNext

        public void positionToNext(DDMFile file,
                          DDMReadCallback listener)
                            throws java.io.IOException
        Positions the cursor to the next record in the file.
        Throws:
        java.io.IOException
      • positionToPrevious

        public void positionToPrevious(DDMFile file,
                              DDMReadCallback listener)
                                throws java.io.IOException
        Positions the cursor to the previous record in the file.
        Throws:
        java.io.IOException
      • positionToFirst

        public void positionToFirst(DDMFile file)
                             throws java.io.IOException
        Positions the cursor to the first record in the file.
        Throws:
        java.io.IOException
      • positionToLast

        public void positionToLast(DDMFile file)
                            throws java.io.IOException
        Positions the cursor to the last record in the file.
        Throws:
        java.io.IOException
      • positionAfterLast

        public void positionAfterLast(DDMFile file)
                               throws java.io.IOException
        Positions the cursor to the end of the file (after the last record).
        Throws:
        java.io.IOException
      • positionBeforeFirst

        public void positionBeforeFirst(DDMFile file)
                                 throws java.io.IOException
        Positions the cursor to the beginning of the file (before the first record).
        Throws:
        java.io.IOException
      • position

        public void position(DDMFile file,
                    DDMReadCallback listener,
                    int recordNumber)
                      throws java.io.IOException
        Positions the cursor to the specified record number.
        Throws:
        java.io.IOException
      • write

        public void write(DDMFile file,
                 byte[] data,
                 int offset,
                 boolean[] nullFieldValues,
                 DDMReadCallback listener)
                   throws java.io.IOException
        Writes a single record to the end of the file.
        Throws:
        java.io.IOException
      • write

        public void write(DDMFile file,
                 DDMWriteCallback listener)
                   throws java.io.IOException
        Writes records provided by the callback to the file.
        Throws:
        java.io.IOException
      • updateCurrent

        public void updateCurrent(DDMFile file,
                         byte[] data,
                         int offset,
                         boolean[] nullFieldValues)
                           throws java.io.IOException
        Updates the current record with the specified data.
        Throws:
        java.io.IOException
      • updateCurrent

        public void updateCurrent(DDMFile file,
                         DDMWriteCallback listener)
                           throws java.io.IOException
        Updates the current record with the first record provided by the callback.
        Throws:
        java.io.IOException
      • execute

        public Message[] execute(java.lang.String command)
                          throws java.io.IOException
        Executes the specified CL command within the DDM host server job.
        Throws:
        java.io.IOException
      • executeReturnMessageList

        public java.util.List<Message> executeReturnMessageList(java.lang.String command)
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • deleteCurrent

        public void deleteCurrent(DDMFile file)
                           throws java.io.IOException
        Removes the current record from the file.
        Throws:
        java.io.IOException