How to attach data from Database into Dataset Property?


We are learning about Weather Module. How can we use Dataset / BasicDataSet datatype available in ignition-common.jar file for adding Dataset property to a Component ?

How can we bind Result set in java which comes from a database to a Dataset data type in Eclipse ?

Can we please get some help on this; we are trying to pass a dataset from Java (JTable or a recordset ) as a property of a new module that we are trying to develop. Not very successful. We have built modules with other properties such as string, list etc but dataset is the one that is most critical for us.

An example of a module that queries a database in Java and then passes the results of the query into a new module as a dataset would be great. We could then assign the dataset property of this new module to other components in ignition such as charts etc.

I’m sorry, I don’t really understand your question very clearly, it seems your terminology is mixed up. When you say “module” do you really mean “component”?

To make a new dataset-type property on a component you’re adding via a module, you would simply have a property of type [tt]com.inductiveautomation.ignition.common.Dataset[/tt], just like any other property. It would have a getter method, a setter method, and an entry in the component’s corresponding BeanInfo property. You would then be able to bind this property just like any other dataset property on any other component.

If instead you’re got Java code that creates a dataset and you’re trying to figure out the best way to assign that dataset to an existing component’s dataset property, you should probably add a new type of ExtensibleBinding to the system. These are what power the “Function” binding types that you see when open the binding window for a dataset property. To add a new function binding, you have your module define a new [tt][/tt] and add it using both the client context and designer context’s [tt]addExtensibleBindingType()[/tt] function.

Hope this helps,

Dear Carl,

We used setDataDirectly method of the BasicDataSet datatype available in com.inductiveautomation.ignition.common. We are able to view the Dataset property in Ignition Designer for the component. However we have following challenges:

  1. When we click on small table icon available for the dataset data type, it is showing NullPointerException. Is it related to Array List building ? What could be the reason for this exception ?
  2. When we binded this property to a Table, the table showing the data. However, when we change the data in Database, the changes are reflected in the Component Dataset property but not in the Binded table.

Please help us to resolve these issues.

Thank you

To build a dataset, you should use one of the constructors so that the data, column names, and column types are all set correctly. Once build, you should consider a Dataset to be immutable.

If the data changes, you must create a new dataset, and replace the old dataset with the new dataset, and then fire a property change event for that property. This event is what will make the binding system work correctly.