# Using "Store and Forward" mechanism from a module (driver)

**URL:** <https://forum.inductiveautomation.com/t/using-store-and-forward-mechanism-from-a-module-driver/12552>\
**Category:** 3rd Party Modules\
**Created:** [January 12, 2017, 9:07am UTC](https://forum.inductiveautomation.com/t/using-store-and-forward-mechanism-from-a-module-driver/12552 "2017-01-12T09:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mik977](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@mik977](https://forum.inductiveautomation.com/u/mik977)\
**Post date:** [January 12, 2017, 9:07am UTC](https://forum.inductiveautomation.com/t/using-store-and-forward-mechanism-from-a-module-driver/12552/1 "2017-01-12T09:07:56Z")

</div>

Hi,

I have a OPC-UA driver that creates an OPC-UA tag tree, but also writes some data to a database. Now I am doing the writing through the SRConnection.runPrepQuery … I wonder if its possible to use the Ignition “Store and Forward” functionality instead. If it’s possible, a short hint would be highly appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [February 14, 2017, 8:50pm UTC](https://forum.inductiveautomation.com/t/using-store-and-forward-mechanism-from-a-module-driver/12552/2 "2017-02-14T20:50:50Z")

</div>

You need to use the history manager to store information through the store and forward. First you need to create a class that implements DatasourceData:

[code]public class QuerySFData implements DatasourceData {  
private static final long serialVersionUID = 1L;

```
    String query;
    String datasource;
    Object[] values;

    public QuerySFData(String query, String datasource) {
            this(query, null, datasource);
    }

    public QuerySFData(String query, Object[] values, String datasource) {
            this.query = query;
            this.values = values;
            this.datasource = datasource;
    }

    @Override
    public int getDataCount() {
            return 1;
    }

    @Override
    public HistoryFlavor getFlavor() {
            return DatasourceData.FLAVOR;
    }

    @Override
    public String getLoggerName() {
            return "Client Store & Forward";
    }

    @Override
    public String getSignature() {
            return "SFQuery: " + datasource + " - " + query;
    }

    @Override
    public void storeToConnection(SRConnection conn) throws Exception {
            if (values != null) {
                    conn.runPrepUpdate(query, values);
            } else {
                    conn.runUpdateQuery(query);
            }
    }

```

}[/code]

Then you just call:

```auto
context.getHistoryManager().storeHistory("YourDataSourceName", new QuerySFData(query, values, datasource));
```
