com.ibm.as400.access

Class AS400File

  • java.lang.Object
    • com.ibm.as400.access.AS400File
  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    KeyedFile, SequentialFile


    public abstract class AS400File
    extends java.lang.Object
    implements java.io.Serializable
    Represents a physical or logical file on the system. This class allows the user to do the following:
    • Create a physical file on the system by:
      • Specifying a record length.
      • Specifying an existing DDS source file.
      • Specifying a RecordFormat object that contains a description of the record format for the file.
    • Access the records in a system file sequentially, by record number, or by key. Note: To read a keyed physical or logical file sequentially and have the records returned in key order, use the read...() methods of KeyedFile.
    • Write records to a system file sequentially or by key.
    • Update records in a system file sequentially, by record number or by key.
    • Lock a system file for different types of access.
    • Use commitment control when accessing a system file. The user can:
      • Start commitment control for the connection.
      • Specify different commitment control lock levels for the individual files being accessed.
      • Commit and rollback transactions for the connection.
    • Delete a physical or logical file or member on the system.
    AS400File objects generate the following events:
    • FileEvent
      The events fired are:
      • FILE_CLOSED
      • FILE_CREATED
      • FILE_DELETED
      • FILE_MODIFIED
      • FILE_OPENED
    • PropertyChangeEvent
    • VetoableChangeEvent
    See Also:
    AS400FileRecordDescription, MemberList, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      AS400File()
      Constructs an AS400File object.
      AS400File(AS400 system, java.lang.String name)
      Constructs an AS400File object.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addFileListener(FileListener listener)
      Adds a listener to be notified when a FileEvent is fired.
      void addPhysicalFileMember(java.lang.String name, java.lang.String textDescription)
      Adds a physical file member to the file represented by this object.
      void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
      Adds a listener to be notified when the value of any bound property is changed.
      void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Adds a listener to be notified when the value of any constrained property is changed.
      void close()
      Closes the file on the system.
      void commit()
      Commits all transactions since the last commit boundary.
      static void commit(AS400 system)
      Commits all transactions since the last commit boundary for the specified system.
      void create(int recordLength, java.lang.String fileType, java.lang.String textDescription)
      Creates a physical file with the specified record length and file type.
      void create(RecordFormat recordFormat, java.lang.String textDescription)
      Creates a physical file using the specified record format.
      void create(RecordFormat recordFormat, java.lang.String textDescription, java.lang.String altSeq, java.lang.String ccsid, java.lang.String order, java.lang.String ref, boolean unique, java.lang.String format, java.lang.String text)
      Creates a physical file using the specified record format and any specified keywords.
      void create(java.lang.String ddsSourceFile, java.lang.String textDescription)
      Creates a physical file using the specified DDS source file.
      void delete()
      Deletes the file.
      void deleteCurrentRecord()
      Deletes the record at the current cursor position.
      void deleteMember()
      Deletes the member associated with this object from the file.
      void endCommitmentControl()
      Ends commitment control for this connection.
      static void endCommitmentControl(AS400 system)
      Ends commitment control for the specified connection.
      protected void finalize()
      Closes the file when this object is garbage collected.
      int getBlockingFactor()
      Returns the blocking factor being used for this file.
      int getCommitLockLevel()
      Returns the commit lock level for this file as specified on open.
      int[] getExplicitLocks()
      Returns the explicit locks that have been obtained for the file using this AS400File object.
      java.lang.String getFileName()
      Returns the file name.
      java.lang.String getLibraryName()
      Returns the library name.
      java.lang.String getMemberName()
      Returns the member name.
      java.lang.String getPath()
      Returns the integrated file system pathname for the file as specified on the constructor or the setPath() method.
      RecordFormat getRecordFormat()
      Returns the record format of this file.
      AS400 getSystem()
      Returns the system object for this object.
      boolean isCommitmentControlStarted()
      Indicates if commitment control is started for the connection.
      static boolean isCommitmentControlStarted(AS400 system)
      Indicates if commitment control is started for the specified system.
      boolean isOpen()
      Indicates if the file is open.
      boolean isReadNoUpdate()
      Indicates if the records should be locked for update when doing reads in a READ_WRITE open mode.
      boolean isReadOnly()
      Indicates if this object is open for read only.
      boolean isReadWrite()
      Indicates if this object is open for read/write.
      boolean isSSPFile()
      Indicates if this object is being treated as an SSP file.
      boolean isWriteOnly()
      Indicates if this object is open for write only.
      void lock(int lockToObtain)
      Obtains a lock on the file.
      void open()
      Opens the file.
      void open(int openType, int blockingFactor, int commitLockLevel)
      Opens the file.
      void positionCursorAfterLast()
      Positions the file cursor to after the last record.
      void positionCursorBeforeFirst()
      Positions the file cursor to before the first record.
      void positionCursorToFirst()
      Positions the file cursor to the first record.
      void positionCursorToLast()
      Positions the file cursor to the last record.
      void positionCursorToNext()
      Positions the file cursor to the next record.
      void positionCursorToPrevious()
      Positions the file cursor to the previous record.
      Record read()
      Reads the record at the current cursor position.
      abstract Record[] readAll()
      Reads all the records in the file.
      Record readFirst()
      Reads the first record in the file.
      Record readLast()
      Reads the last record in the file.
      Record readNext()
      Reads the next record in the file from the current cursor position.
      Record readPrevious()
      Reads the previous record in the file from the current cursor position.
      void refreshRecordCache()
      Refreshes the record cache for this file.
      void releaseExplicitLocks()
      Releases all locks acquired via the lock() method.
      void removeFileListener(FileListener listener)
      Removes a listener from the file listeners list.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      Removes a listener from the change list.
      void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Removes a listener from the veto change listeners list.
      void rollback()
      Rolls back any transactions since the last commit/rollback boundary.
      static void rollback(AS400 system)
      Rolls back any transactions since the last commit/rollback boundary for the specified system.
      AS400Message[] runCommand(java.lang.String command)
      Runs a CL command in the DDM host server job.
      void setPath(java.lang.String name)
      Sets the integrated file system pathname for the file.
      void setReadNoUpdate(boolean readNoUpdate)
      Sets the readNoUpdate flag, which determines whether the records should be locked for update when doing reads or positionCursor operations in a READ_WRITE open mode.
      void setRecordFormat()
      Sets the record format to be used for this file.
      void setRecordFormat(int recordFormat)
      Sets the record format to be used for this file.
      void setRecordFormat(RecordFormat recordFormat)
      Sets the record format to be used for this file.
      void setRecordFormat(java.lang.String recordFormat)
      Sets the record format to be used for this file.
      void setSSPFile(boolean treatAsSSP)
      Sets the SSP flag for this file.
      void setSystem(AS400 system)
      Sets the system to which to connect.
      static void startCommitmentControl(AS400 system, int commitLockLevel)
      Starts commitment control for the specified system.
      void startCommitmentControl(int commitLockLevel)
      Starts commitment control on this file (for this connection).
      void update(Record record)
      Updates the record at the current cursor position.
      void write(Record record)
      Writes a record to the file.
      void write(Record[] records)
      Writes an array of records to the file.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • longRecordNumber

        protected boolean longRecordNumber
      • COMMIT_LOCK_LEVEL_ALL

        public static final int COMMIT_LOCK_LEVEL_ALL
        Constant indicating a commit lock level of *ALL. Every record accessed in the file is locked until the transaction is committed or rolled back.
        See Also:
        startCommitmentControl(int), Constant Field Values
      • COMMIT_LOCK_LEVEL_CHANGE

        public static final int COMMIT_LOCK_LEVEL_CHANGE
        Constant indicating a commit lock level of *CHANGE. Every record read for update is locked. If a record is updated, added, or deleted, that record remains locked until the transaction is committed or rolled back. Records that are accessed for update but are released without being updated are unlocked.
        See Also:
        startCommitmentControl(int), Constant Field Values
      • COMMIT_LOCK_LEVEL_CURSOR_STABILITY

        public static final int COMMIT_LOCK_LEVEL_CURSOR_STABILITY
        Constant indicating a commit lock level of *CS. Every record accessed is locked. Records that are not updated or deleted are locked only until a different record is accessed. Records that are updated, added, or deleted are locked until the transaction is committed or rolled back.
        See Also:
        startCommitmentControl(int), Constant Field Values
      • COMMIT_LOCK_LEVEL_DEFAULT

        public static final int COMMIT_LOCK_LEVEL_DEFAULT
        Constant indicating that the commit lock level specified on the startCommitmentControl() method should be used. The record locking specified by the commitLockLevel parameter on the startCommitmentControl() method will apply to transactions using this file.
        See Also:
        Constant Field Values
      • COMMIT_LOCK_LEVEL_NONE

        public static final int COMMIT_LOCK_LEVEL_NONE
        Constant indicating that no commitment control should be used for the file. No commitment control will apply to this file.
        See Also:
        startCommitmentControl(int), Constant Field Values
      • READ_ALLOW_SHARED_READ_LOCK

        public static final int READ_ALLOW_SHARED_READ_LOCK
        Constant indicating lock type of read willing to share with other readers. This is the equivalent of specifying *SHRNUP on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
      • READ_ALLOW_SHARED_WRITE_LOCK

        public static final int READ_ALLOW_SHARED_WRITE_LOCK
        Constant indicating lock type of read willing to share with updaters. This is the equivalent of specifying *SHRRD on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
      • READ_EXCLUSIVE_LOCK

        public static final int READ_EXCLUSIVE_LOCK
        Constant indicating lock type of read willing to share with no one. This is the equivalent of specifying *EXCL on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
      • WRITE_ALLOW_SHARED_READ_LOCK

        public static final int WRITE_ALLOW_SHARED_READ_LOCK
        Constant indicating lock type of update willing to share with readers. This is the equivalent of specifying *EXCLRD on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
      • WRITE_ALLOW_SHARED_WRITE_LOCK

        public static final int WRITE_ALLOW_SHARED_WRITE_LOCK
        Constant indicating lock type of update willing to share with updaters. This is the equivalent of specifying *SHRUPD on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
      • WRITE_EXCLUSIVE_LOCK

        public static final int WRITE_EXCLUSIVE_LOCK
        Constant indicating lock type of update willing to share with no one. This is the equivalent of specifying *EXCL on the Allocate Object (ALCOBJ) command.
        See Also:
        lock(int), Constant Field Values
    • Constructor Detail

      • AS400File

        public AS400File()
        Constructs an AS400File object.
      • AS400File

        public AS400File(AS400 system,
                 java.lang.String name)
        Constructs an AS400File object. It uses the system and file name specified. If the name for the file does not include a member, the first member of the file will be used.
        Parameters:
        system - The system to which to connect. The system cannot be null.
        name - The integrated file system pathname of the file. The name cannot be null.
    • Method Detail

      • addPhysicalFileMember

        public void addPhysicalFileMember(java.lang.String name,
                                 java.lang.String textDescription)
                                   throws AS400Exception,
                                          AS400SecurityException,
                                          java.lang.InterruptedException,
                                          java.io.IOException
        Adds a physical file member to the file represented by this object.
        Parameters:
        name - The name of the member to create. The name cannot exceed 10 characters in length. The name cannot be null.
        textDescription - The text description with which to create the file. This value must be 50 characters or less. If this value is null, the text description will be blank.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • addPropertyChangeListener

        public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
        Adds a listener to be notified when the value of any bound property is changed. The propertyChange method will be be called.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        removePropertyChangeListener(java.beans.PropertyChangeListener)
      • addVetoableChangeListener

        public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Adds a listener to be notified when the value of any constrained property is changed. The vetoableChange method will be called.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        removeVetoableChangeListener(java.beans.VetoableChangeListener)
      • close

        public void close()
                   throws AS400Exception,
                          AS400SecurityException,
                          java.lang.InterruptedException,
                          java.io.IOException
        Closes the file on the system. All file locks held by this connection are released. All uncommitted transactions against the file are rolled back if commitment control has been started.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • commit

        public void commit()
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Commits all transactions since the last commit boundary. Invoking this method will cause all transactions under commitment control for this connection to be committed. This means that any AS400File object opened under this connection, for which a commit lock level was specified, will have outstanding transactions committed. If commitment control has not been started for the connection, no action is taken.
        The system to which to connect must be set prior to invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • commit

        public static void commit(AS400 system)
                           throws AS400Exception,
                                  AS400SecurityException,
                                  java.lang.InterruptedException,
                                  java.io.IOException
        Commits all transactions since the last commit boundary for the specified system. Invoking this method will cause all transactions under commitment control for the specified connection to be committed. This means that any AS400File object opened under this connection, for which a commit lock level was specified, will have outstanding transactions committed. If commitment control has not been started for the connection, no action is taken.
        Parameters:
        system - The system for which transactions will be committed.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • create

        public void create(int recordLength,
                  java.lang.String fileType,
                  java.lang.String textDescription)
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Creates a physical file with the specified record length and file type. The record format for this object will be set by this method. The record format for the file is determined as follows:
        • If fileType is AS400File.TYPE_DATA,
          • The format name of the file is the name of the file as specified on the constructor
          • The record format contains one field whose name is the name of the file, whose type is CHARACTER, and whose length is recordLength
        • If fileType is AS400File.TYPE_SOURCE,
          • The format name of the file is the name of the file as specified on the constructor
          • The record format contains three fields:
            • SRCSEQ whose type is ZONED(6, 2)
            • SRCDAT whose type is ZONED(6, 0)
            • SRCDTA whose type is CHARACTER and whose length is recordLength - 12
        Note: The file is created using the default values for the Create Physical File (CRTPF) command. To change the file after it has been created, use the CommandCall class to issue a CHGPF command.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Parameters:
        recordLength - The record length with which to create the file. Valid values are 1 through 32766 inclusive.
        fileType - The file type with which to create the file. Valid values are AS400File.TYPE_DATA or AS400File.TYPE_SOURCE. If AS400File.TYPE_DATA is specified, the record format for the file contains one field. If AS400File.TYPE_SOURCE is specified, the record format for the file contains three fields: source sequence number, date, and source statement.
        textDescription - The text description with which to create the file. This value must be 50 characters or less. If this value is null, the empty string, or AS400File.BLANK, the text description is blank.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • create

        public void create(java.lang.String ddsSourceFile,
                  java.lang.String textDescription)
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Creates a physical file using the specified DDS source file. Note: The file is created using the default values for the Create Physical File (CRTPF) command. To change the file after it has been created, use the CommandCall class to issue a CHGPF command.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Parameters:
        ddsSourceFile - The integrated file system pathname of the file containing the DDS source for the file being created.
        textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or AS400File.BLANK, the text description will be blank. Specify AS400File.SOURCE_MEMBER_TEXT for the text description if the text description from ddsSourceFile is to be used.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • create

        public void create(RecordFormat recordFormat,
                  java.lang.String textDescription)
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Creates a physical file using the specified record format. The record format for this object will be set by this method. Note: The file is created using the default values for the Create Physical File (CRTPF) command. To change the file after it has been created, use the CommandCall class to issue a CHGPF command.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Parameters:
        recordFormat - The record format for the file.
        textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or AS400File.BLANK, the text description will be blank.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • create

        public void create(RecordFormat recordFormat,
                  java.lang.String textDescription,
                  java.lang.String altSeq,
                  java.lang.String ccsid,
                  java.lang.String order,
                  java.lang.String ref,
                  boolean unique,
                  java.lang.String format,
                  java.lang.String text)
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Creates a physical file using the specified record format and any specified keywords. The record format for this object will be set by this method. Note: The file is created using the default values for the Create Physical File (CRTPF) command. To change the file after it has been created, use the CommandCall class to issue a CHGPF command.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Parameters:
        recordFormat - The record format of the file.
        textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or AS400File.BLANK, the text description will be blank.
        altSeq - The value to be specified for the file-level keyword ALTSEQ. If no value is to be specified, null may be specified.
        ccsid - The value to be specified for the file-level keyword CCSID. If no value is to be specified, null may be specified.
        order - The value to be specified to indicate in which order records will be retrieved from the file. Valid values are one of the following file-level keywords:
        • FIFO
        • LIFO
        • FCFO
        If no ordering value is to be specified, null may be specified.
        ref - The value to be specified for the file-level keyword REF. If no value is to be specified, null may be specified.
        unique - The value that indicates if the file-level keyword UNIQUE is to be specified. true if UNIQUE should be specified; false otherwise.
        format - The value to be specified for the record-level keyword FORMAT. If no value is to be specified, null may be specified.
        text - The value to be specified for the record-level keyword TEXT. If no value is to be specified, null may be specified. The single quotes required to surround the TEXT keyword value are added by this class.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400)
      • deleteCurrentRecord

        public void deleteCurrentRecord()
                                 throws AS400Exception,
                                        AS400SecurityException,
                                        java.lang.InterruptedException,
                                        java.io.IOException
        Deletes the record at the current cursor position. The file must be open and the cursor must be positioned on an active record.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • endCommitmentControl

        public void endCommitmentControl()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Ends commitment control for this connection. If commitment control has not been started for the connection, no action is taken.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • endCommitmentControl

        public static void endCommitmentControl(AS400 system)
                                         throws AS400Exception,
                                                AS400SecurityException,
                                                java.lang.InterruptedException,
                                                java.io.IOException
        Ends commitment control for the specified connection. If commitment control has not been started for the connection, no action is taken.
        Parameters:
        system - The system for which commitment control should be ended.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Closes the file when this object is garbage collected.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable - If an exception is thrown while cleaning up.
      • getBlockingFactor

        public int getBlockingFactor()
        Returns the blocking factor being used for this file.
        Returns:
        The blocking factor for this file. Zero will be returned if the file is not open.
        See Also:
        open()
      • getCommitLockLevel

        public int getCommitLockLevel()
        Returns the commit lock level for this file as specified on open.
        Returns:
        The commit lock level for this file. If commitment control has not been started for the connection or if file has not been opened, -1 is returned. Possible return values are:
        • COMMIT_LOCK_LEVEL_ALL
        • COMMIT_LOCK_LEVEL_CHANGE
        • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
        • COMMIT_LOCK_LEVEL_DEFAULT
        • COMMIT_LOCK_LEVEL_NONE
        • -1
      • getExplicitLocks

        public int[] getExplicitLocks()
        Returns the explicit locks that have been obtained for the file using this AS400File object. Any locks that have been obtained through the lock(int) method on this AS400File object are returned. Note that this method does not return any locks that have been obtained by using the ALCOBJ CL command or by using a different AS400File object created to reference the same physical file.
        Returns:
        The explicit file locks held for the file by this AS400File object. Possible lock values are:
        • READ_EXCLUSIVE_LOCK
        • READ_ALLOW_SHARED_READ_LOCK
        • READ_ALLOW_SHARED_WRITE_LOCK
        • WRITE_EXCLUSIVE_LOCK
        • WRITE_ALLOW_SHARED_READ_LOCK
        • WRITE_ALLOW_SHARED_WRITE_LOCK
        If no explicit locks have been obtained for the file using this AS400File object, an array of size zero is returned. Note that this does not necessarily indicate that the actual physical file has not itself been locked by some other means.
        See Also:
        lock(int)
      • getFileName

        public java.lang.String getFileName()
        Returns the file name.
        Returns:
        The file name. If the integrated file system pathname has not been set for the object, an empty string is returned.
      • getLibraryName

        public java.lang.String getLibraryName()
        Returns the library name.
        Returns:
        The library name. If the integrated file system pathname has not been set for the object, an empty string is returned.
      • getMemberName

        public java.lang.String getMemberName()
        Returns the member name.
        Returns:
        The member name. If the special value %FIRST% or %LAST% was specified for the member portion of the file name and the file is not open, the special value is returned. If the special value %FIRST% or %LAST% was specified for the member portion of the file name and the file is open, the member name is returned. If the integrated file system pathname has not been set for the object, an empty string is returned.
      • getPath

        public java.lang.String getPath()
        Returns the integrated file system pathname for the file as specified on the constructor or the setPath() method.
        Returns:
        The integrated file system pathname associated with this object. If the integrated file system pathname has not been set for the object, an empty string is returned.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String)
      • isCommitmentControlStarted

        public boolean isCommitmentControlStarted()
        Indicates if commitment control is started for the connection.
        Returns:
        true if commitment control has been started; false otherwise.
      • isCommitmentControlStarted

        public static boolean isCommitmentControlStarted(AS400 system)
        Indicates if commitment control is started for the specified system.
        Parameters:
        system - The system that is checked to determine if commitment control is started.
        Returns:
        true if commitment control has been started for the connection; false otherwise.
      • isOpen

        public boolean isOpen()
        Indicates if the file is open.
        Returns:
        true if the file is open; false otherwise.
      • isReadNoUpdate

        public boolean isReadNoUpdate()
        Indicates if the records should be locked for update when doing reads in a READ_WRITE open mode. By default, the records will be locked for update when doing reads in a READ_WRITE open mode.
        Returns:
        true if the records should not be locked for update when doing reads in a READ_WRITE open mode; false otherwise.
        See Also:
        setReadNoUpdate(boolean)
      • isReadOnly

        public boolean isReadOnly()
        Indicates if this object is open for read only.
        Returns:
        true if the file is open for read only; false otherwise.
      • isReadWrite

        public boolean isReadWrite()
        Indicates if this object is open for read/write.
        Returns:
        true if the file is open for read/write; false otherwise.
      • isSSPFile

        public boolean isSSPFile()
        Indicates if this object is being treated as an SSP file. This method just returns the value set using setSSPFile().
        Returns:
        true if the file is being treated as an SSP file; false if it is being treated as a normal DDM file. The default is false.
        See Also:
        setSSPFile(boolean)
      • isWriteOnly

        public boolean isWriteOnly()
        Indicates if this object is open for write only.
        Returns:
        true if the file is open for write only; false otherwise.
      • open

        public void open(int openType,
                int blockingFactor,
                int commitLockLevel)
                  throws AS400Exception,
                         AS400SecurityException,
                         java.lang.InterruptedException,
                         java.io.IOException
        Opens the file. The file must not be open when invoking this method. If commitment control is not started for the connection, commitLockLevel is ignored. The file cursor is positioned prior to the first record. If blockingFactor is greater than one (or if zero is specified and a blocking factor greater than one is determined by the object) and the file is opened for READ_ONLY, the record cache will be filled with an initial set of records.
        The record format for the file must be set prior to calling this method.
        The name of the file and the system to which to connect must be set prior to invoking this method.
        Parameters:
        openType - The manner in which to open the file. Valid values are:
        • READ_ONLY
        • READ_WRITE
        • WRITE_ONLY
        If the openType is WRITE_ONLY, the various positionCursor() methods will fail since write() operations are appended to the end of the file.
        blockingFactor - The number of records to retrieve or to write during a read or write operation.
        The AS400File object will attempt to anticipate the need for data by accessing blocks of records if the openType is READ_ONLY.
        If the openType is WRITE_ONLY, blockingFactor number of records will be written at one time when writing an array of records.
        If the open type is READ_WRITE, blockingFactor is ignored and a blocking factor of 1 will be used for data integrity reasons. Specify an appropriate blockingFactor for your performance needs.
        If 0 is specified for blockingFactor, a default value will be calculated by taking the integer result of dividing 2048 by the byte length of the record plus 16.
        If the user specifies a blocking factor greater than 1 or specifies 0, which will cause a blocking factor to be calculated, there is the risk of obtaining stale data when doing multiple read operations. Invoke the refreshRecordCache() method prior to reading a record to cause the object to read from the system if this is a problem.
        commitLockLevel - Used to control record locking during a transaction if commitment control has been started for the connection. Valid values are:
        • COMMIT_LOCK_LEVEL_ALL
        • COMMIT_LOCK_LEVEL_CHANGE
        • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
        • COMMIT_LOCK_LEVEL_DEFAULT
        • COMMIT_LOCK_LEVEL_NONE
        The commitLockLevel is ignored if commitment control is not started for the connection.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        AS400File(com.ibm.as400.access.AS400, java.lang.String), setPath(java.lang.String), setSystem(com.ibm.as400.access.AS400), refreshRecordCache(), setRecordFormat()
      • positionCursorAfterLast

        public void positionCursorAfterLast()
                                     throws AS400Exception,
                                            AS400SecurityException,
                                            java.lang.InterruptedException,
                                            java.io.IOException
        Positions the file cursor to after the last record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • positionCursorBeforeFirst

        public void positionCursorBeforeFirst()
                                       throws AS400Exception,
                                              AS400SecurityException,
                                              java.lang.InterruptedException,
                                              java.io.IOException
        Positions the file cursor to before the first record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • positionCursorToFirst

        public void positionCursorToFirst()
                                   throws AS400Exception,
                                          AS400SecurityException,
                                          java.lang.InterruptedException,
                                          java.io.IOException
        Positions the file cursor to the first record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • positionCursorToLast

        public void positionCursorToLast()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Positions the file cursor to the last record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • positionCursorToNext

        public void positionCursorToNext()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Positions the file cursor to the next record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • positionCursorToPrevious

        public void positionCursorToPrevious()
                                      throws AS400Exception,
                                             AS400SecurityException,
                                             java.lang.InterruptedException,
                                             java.io.IOException
        Positions the file cursor to the previous record. The file must be open when invoking this method.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • read

        public Record read()
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Reads the record at the current cursor position. The file must be open when invoking this method. The cursor position does not change when this method is invoked.
        Returns:
        The record read.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • readAll

        public abstract Record[] readAll()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Reads all the records in the file. The file must be closed when invoking this method. The record format for the file must have been set prior to invoking this method.
        Returns:
        The records read. If no records are read, an array of size zero is returned.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
      • readFirst

        public Record readFirst()
                         throws AS400Exception,
                                AS400SecurityException,
                                java.lang.InterruptedException,
                                java.io.IOException
        Reads the first record in the file. The file must be open when invoking this method. The cursor is positioned to the first record of the file as a result of invoking this method.
        Returns:
        The record read.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • readLast

        public Record readLast()
                        throws AS400Exception,
                               AS400SecurityException,
                               java.lang.InterruptedException,
                               java.io.IOException
        Reads the last record in the file. The file must be open when invoking this method. The cursor is positioned to the last record of the file as a result of invoking this method.
        Returns:
        The record read.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • readNext

        public Record readNext()
                        throws AS400Exception,
                               AS400SecurityException,
                               java.lang.InterruptedException,
                               java.io.IOException
        Reads the next record in the file from the current cursor position. The file must be open when invoking this method. The cursor is positioned to the first active record after the current cursor position as a result of invoking this method. If this method is invoked when the cursor is positioned at the last record of the file, null will be returned and the cursor is positioned after the last record of the file.
        Returns:
        The record read.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • readPrevious

        public Record readPrevious()
                            throws AS400Exception,
                                   AS400SecurityException,
                                   java.lang.InterruptedException,
                                   java.io.IOException
        Reads the previous record in the file from the current cursor position. The file must be open when invoking this method. The cursor is positioned to the first active record prior to the current cursor position as a result of invoking this method. If this method is invoked when the cursor is positioned at the first record of the file, null is returned and the cursor is positioned before the first record of the file.
        Returns:
        The record read.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • refreshRecordCache

        public void refreshRecordCache()
                                throws AS400Exception,
                                       AS400SecurityException,
                                       java.lang.InterruptedException,
                                       java.io.IOException
        Refreshes the record cache for this file. Invoking this method will cause the retrieval of records from the system. The cursor position is set to the first record of the file. This method only needs to be invoked if a blocking factor greater than 1 is being used, and the user wants to refresh the records in the cache. The file must be open when invoking this method. No action is taken if records are not being cached (for example, the blocking factor is set to one).
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • releaseExplicitLocks

        public void releaseExplicitLocks()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Releases all locks acquired via the lock() method. If no locks have been explicitly obtained, no action is taken.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
        See Also:
        lock(int)
      • removePropertyChangeListener

        public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
        Removes a listener from the change list. If the listener is not on the list, does nothing.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        addPropertyChangeListener(java.beans.PropertyChangeListener)
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Removes a listener from the veto change listeners list. If the listener is not on the list, does nothing.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        addVetoableChangeListener(java.beans.VetoableChangeListener)
      • rollback

        public void rollback()
                      throws AS400Exception,
                             AS400SecurityException,
                             java.lang.InterruptedException,
                             java.io.IOException
        Rolls back any transactions since the last commit/rollback boundary. Invoking this method will cause all transactions under commitment control for this connection to be rolled back. This means that any AS400File object for which a commit lock level was specified and that was opened under this connection will have outstanding transactions rolled back.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
      • rollback

        public static void rollback(AS400 system)
                             throws AS400Exception,
                                    AS400SecurityException,
                                    java.lang.InterruptedException,
                                    java.io.IOException
        Rolls back any transactions since the last commit/rollback boundary for the specified system. Invoking this method will cause all transactions under commitment control for this connection to be rolled back. This means that any AS400File object for which a commit lock level was specified and that was opened under this connection will have outstanding transactions rolled back.
        Parameters:
        system - The system for which transactions will be rolled back.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
      • runCommand

        public AS400Message[] runCommand(java.lang.String command)
                                  throws AS400SecurityException,
                                         java.lang.InterruptedException,
                                         java.io.IOException
        Runs a CL command in the DDM host server job. This is useful for changing the IASP used by the DDM server for the currently connected AS400 object, changing library lists, etc.

        Note: If using Toolbox native optimizations, the CL command will run in the current job, since there will not be an associated DDM host server job.

        Parameters:
        command - The CL command to run.
        Returns:
        The list of AS400Message objects output by the CL command (if any).
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        See Also:
        CommandCall
      • setPath

        public void setPath(java.lang.String name)
                     throws java.beans.PropertyVetoException
        Sets the integrated file system pathname for the file.
        Parameters:
        name - The integrated file system pathname of the file.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setReadNoUpdate

        public void setReadNoUpdate(boolean readNoUpdate)
        Sets the readNoUpdate flag, which determines whether the records should be locked for update when doing reads or positionCursor operations in a READ_WRITE open mode.
        Parameters:
        readNoUpdate - true if the records should not be locked for update when doing reads in a READ_WRITE open mode; false otherwise.
        See Also:
        isReadNoUpdate()
      • setRecordFormat

        public void setRecordFormat()
                             throws AS400Exception,
                                    AS400SecurityException,
                                    java.lang.InterruptedException,
                                    java.io.IOException,
                                    java.beans.PropertyVetoException
        Sets the record format to be used for this file. Retrieves the record format(s) from the file on the system and sets the record format to be the first format retrieved from the file. Calling this method is the same as calling setRecordFormat(0). The record format must be set prior to invoking open() or readAll().
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        AS400FileRecordDescription.retrieveRecordFormat()
      • setRecordFormat

        public void setRecordFormat(int recordFormat)
                             throws AS400Exception,
                                    AS400SecurityException,
                                    java.lang.InterruptedException,
                                    java.io.IOException,
                                    java.beans.PropertyVetoException
        Sets the record format to be used for this file. Retrieves the record format(s) from the file on the system and sets the record format to the recordFormat one. The record format must be set prior to invoking open() or readAll().
        Parameters:
        recordFormat - The index of the record format to be used.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        AS400FileRecordDescription.retrieveRecordFormat()
      • setRecordFormat

        public void setRecordFormat(java.lang.String recordFormat)
                             throws AS400Exception,
                                    AS400SecurityException,
                                    java.lang.InterruptedException,
                                    java.io.IOException,
                                    java.beans.PropertyVetoException
        Sets the record format to be used for this file. Retrieves the record format(s) from the file on the system and sets the record format to be recordFormat. The record format must be set prior to invoking open() or readAll().
        Parameters:
        recordFormat - The name of the record format to be used.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        AS400FileRecordDescription.retrieveRecordFormat()
      • setRecordFormat

        public void setRecordFormat(RecordFormat recordFormat)
                             throws java.beans.PropertyVetoException
        Sets the record format to be used for this file. The record format must be set prior to invoking open() or readAll().

        Note: This method is not supported for multi-format logical files. Multi-format logical files must use one of the other setRecordFormat() methods.

        Parameters:
        recordFormat - The record format for this file.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        setRecordFormat(int), setRecordFormat(java.lang.String)
      • setSSPFile

        public void setSSPFile(boolean treatAsSSP)
        Sets the SSP flag for this file. This flag indicates whether or not to treat the file on the system as a System/36 SSP file. When set to true, the record format name is ignored. When set to false, the file is treated as a normal physical or logical DDM file. The default is false.
        Parameters:
        treatAsSSP - The flag indicating how to treat the file.
        See Also:
        isSSPFile()
      • setSystem

        public void setSystem(AS400 system)
                       throws java.beans.PropertyVetoException
        Sets the system to which to connect.
        Parameters:
        system - The system to which to connect.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • startCommitmentControl

        public void startCommitmentControl(int commitLockLevel)
                                    throws AS400Exception,
                                           AS400SecurityException,
                                           java.lang.InterruptedException,
                                           java.io.IOException
        Starts commitment control on this file (for this connection). If commitment control has already been started for the connection, an exception is thrown.
        Parameters:
        commitLockLevel - The type of commitment control to exercise. Valid values are:
        • COMMIT_LOCK_LEVEL_ALL
        • COMMIT_LOCK_LEVEL_CHANGE
        • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
      • startCommitmentControl

        public static void startCommitmentControl(AS400 system,
                                  int commitLockLevel)
                                           throws AS400Exception,
                                                  AS400SecurityException,
                                                  java.lang.InterruptedException,
                                                  java.io.IOException
        Starts commitment control for the specified system. If commitment control has already been started for the connection, an exception is thrown.
        Parameters:
        system - The system for which commitment control should be started.
        commitLockLevel - The type of commitment control to exercise. Valid values are:
        • COMMIT_LOCK_LEVEL_ALL
        • COMMIT_LOCK_LEVEL_CHANGE
        • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ServerStartupException - If the host server cannot be started.
        java.net.UnknownHostException - If the system cannot be located.
      • update

        public void update(Record record)
                    throws AS400Exception,
                           AS400SecurityException,
                           java.lang.InterruptedException,
                           java.io.IOException
        Updates the record at the current cursor position. The file must be open when invoking this method. The cursor must be positioned to an active record. The last operation on the file must have been a cursor positioning operation or a read operation. If an attempt is made to update a record more than once without reading the record or positioning the cursor to the record in between updates, an AS400Exception is thrown. The cursor position is not changed when this method is invoked.
        Parameters:
        record - The record with which to update. The record must be a record whose format matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain a default record whose fields can be set appropriately by the Java program and then written to the file.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • write

        public void write(Record record)
                   throws AS400Exception,
                          AS400SecurityException,
                          java.lang.InterruptedException,
                          java.io.IOException
        Writes a record to the file. The file must be open when invoking this method. The record is written to the end of the file. The cursor is positioned to after the last record of the file as a result of invoking this method.
        Parameters:
        record - The record to write. The record must be a record whose format matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain a default record whose fields can be set appropriately by the Java program and then written to the file.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
      • write

        public void write(Record[] records)
                   throws AS400Exception,
                          AS400SecurityException,
                          java.lang.InterruptedException,
                          java.io.IOException
        Writes an array of records to the file. The file must be open when invoking this method. The records are written to the end of the file. The cursor is positioned to after the last record of the file as a result of invoking this method.
        Parameters:
        records - The records to write. The records must have a format which matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain default records whose fields can be set appropriately by the Java program and then written to the file.
        Throws:
        AS400Exception - If the system returns an error message.
        AS400SecurityException - If a security or authority error occurs.
        ConnectionDroppedException - If the connection is dropped unexpectedly.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.