Skip to content

How to get the DataType of an UaNode?

I am using the eclipse-milo`s jars, version 0.5.3.

I would like to read specific nodes, and store their values in a database. I intend to dynamically construct the database column, taking into consideration the data type. For example: a node of type Float (Identifiers.Float) would be a FLOAT in the database.

I can connect to an OPCUA Server, retrieve the AddressSpace and read the node value.

UaNode node = uaClient.getAddressSpace().getNode(nodeId);
DataValue dataValue = node.readAttribute(AttributeId.Value);
Object value = dataValue.getValue().getValue();

How can I read the type of the value of a given Node? In the above example, the datatype of node. I have tried the following:

Optional<ExpandedNodeId> dataType = dataValue.getValue().getDataType();        
if (dataType.isPresent()) {
    ExpandedNodeId nodeDataType = dataType.get();

The identifier of the data type is received (ns=0;i=10), but not the type.


DataType’s in OPC UA are identified by a NodeId, so what you’re seeing is normal.

If you need assistance resolving a datatype to a “backing” class you might look at the DataTypeTree class for assistance:

DataTypeTree tree =;

UaVariableNode currentTimeNode = client.getAddressSpace()

NodeId dataType = currentTimeNode.getDataType();

Class<?> clazz = tree.getBackingClass(dataType);

System.out.println(clazz); // class org.eclipse.milo.opcua.stack.core.types.builtin.DateTime