ConnectorLib Java 23.4

# Create a Datastore

The datastore features are all contained within the `com.autonomy.connector` namespace. The samples in this section assume there is an import directive for this namespace at the beginning of the file:

           import com.autonomy.connector.*;

You can access a datastore for the synchronize action like this:

           public void synchronize(SynchronizeTask task)
           {
               Datastore datastore = new Datastore(
                      task.getDatastoreFilename(),
                      task.getLog());

               //Use datastore

               datastore.close();
           }

This opens or creates the datastore in the file named in `task.getDatastoreFilename()`. If the datastore already exists the existing datastore is opened (the datastore is not created again). The `Datastore` object provides access to the datastore.

## Best Practice

OpenText recommends that you use the file named in `SynchronizeTask.getDatastoreFilename()` to store all state information for the task. You can use the ``Datastore`` object to store a datastore in that file, or use a format of your choosing.

The advantages of storing all state information in the file specified by `SynchronizeTask.getDatastoreFilename()` include:

- ConnectorLib Java chooses a unique file name that does not conflict with the names used for other tasks. The file name also respects configuration settings regarding the datastore location.
- The same file name is provided to other actions called for the same task (collect, view, insert, update, and so on.)
- The file is backed up and restored automatically if the `backup` and `restore` actions are used.

Copyright 2022 Open Text
Version 23.4 | Last updated September 2023

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to swpdl.idoldocsfeedback@microfocus.com.

We appreciate your feedback!

Product: IDOL ConnectorLib Java 23.4

Topic Title: Create a Datastore