Skip to end of metadata
Go to start of metadata

You can access Cassandra to display data using a Jaggery function. Within that function you can query the database and retrieve the required data The steps below demonstrates an example on accessing Cassandra using Jaggery.

  1. Download cassandra-jdbc-1.1.1.wso2v1.jar file and place it in <BAM_HOME>/repository/components/lib/ directory.
  2. Add below datasource to <BAM_HOME>/repository/conf/datasources/master-datasources.xml file ad edit the configurations as required.  

    <description>The datasource used for connect to cassandra db</description>
    <definition type="RDBMS">
    <validationQuery>SELECT COUNT(*) from system.local</validationQuery>

    The JDBC Cassandra driver used in the above configuration allows you to connect to one Cassandra node. Thereby, it does not support configuring multiple connections to several nodes in a Cassandra cluster.

  3. Add the below code snippet as a Jaggery file in <BAM_HOME>/repository/deployment/server/jaggeryapps/ directory, to access and query the Cassandra datasource. 

    var db = new Database("Cassandra_Query");
    var result;
    result = db.query("SELECT * FROM org_wso2_ticket_service");

    In the above code snippet, Cassandra_Query is the name of the datasource, which you created above, and org_wso2_ticket_service is the name of the column family.

  • No labels