Package jason.bb

Class JDBCPersistentBB

All Implemented Interfaces:
ToDOM, Cloneable, Iterable<Literal>
Direct Known Subclasses:
AgentJDBCPersistentBB

public class JDBCPersistentBB extends ChainBBAdapter
Implementation of BB that stores some beliefs in a relational data base.

The parameters for this customisation are:

  • args[0] is the Database Engine JDBC drive
  • args[1] is the JDBC URL connection string
    The url can use the agent name as parameter as in "jdbc:mysql://localhost/%s". In this case, %s will be replaced by the agent's name.
  • args[2] is the username
  • args[3] is the password
  • args[4] is an AS list with all beliefs that are mapped to DB. Each element of the list is in the form

    predicate(arity [, table_name [, columns]])

    and columns is in the form

    columns( col_name(col_type), col_name(col_type), ....)

Example in .mas2j project, the agent c uses a JDBC belief base:

 agents:
   c beliefBaseClass jason.bb.JDBCPersistentBB(
      "org.hsqldb.jdbcDriver", // driver for HSQLDB
      "jdbc:hsqldb:bookstore", // URL connection
      "sa", // user
      "", // password
      "[a(1,tablea,columns(runs(integer))),
        book(5),
        book_author(2),
        author(2,author,columns(id(integer),name(varchar(30)))),
        publisher(2)]");
   

The predicate a/1 is mapped to a table called "tablea" with an integer column called runs; predicate book (with arity 5) is mapped to a table called "book"; and so on.

The name and type of the columns are used only if the table does not exits and have to be created. If no column name/type is provided, an arbitrary name is used with type varchar(256). If no table name is provided, the predicate name is used for the table name.