Rule using input from mariaDB

OK, this shows some confusion.

You chose “vnd.openhab.dsl.rule” as the rules language. Rules DSL is not Java. It has access to the core Java classes and a number of the Classes that make up openHAB, but it is not Java in structure, syntax nor how it works overall.

If you want to create rules in Java, you need to install the Java Rule add-on from the marketplace. But the last time I looked that does not support creating rules through the UI.

Other rules languages available through separate add-ons include:

  • JS Scripting (ECMAScript 2021+), enables Blockly
  • jRuby
  • Jython
  • Groovy
  • HABApp
  • NodeRed

Lots of options are available but the answer will depend on what language you want to use for your rules. If Rules DSL, see Design Pattern: Encoding and Accessing Values in Rules.

If you use Js Scripting, jRuby, Jython, or HABApp it’s likely you can import and use a native MariaDB driver to access the database directly.

And in any of these you can store mappings in files, hard coded in Item metadata (not available in Rules DSL), etc.