[Solved] Session Management in Jaggery.js [closed]


To connect Jaggery to MySQL, you need to download JDBC driver jar to <jaggery>\carbon\repository\components\dropins\ directory.
In MySQL, create new database sodb by typing: mysql> create database sodb.

the example below shows how to create table, insert data in MySQL and view the data using Jaggery.

  1. Create folder sodbmysql in /apps/
  2. Create sodb.jag file in the sodbmysql folder then add this code in the file:

     <%
    var query1 = "CREATE TABLE example(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT);";
    config = {};
    var db = new Database("jdbc:mysql://<mysql host>:<port>/<database>", "<mysql_username>", "<mysql_password>", config);
    try{db.query(query1); print('Created the table');}
    catch(e){print(e.toString());}
    finally{db.close();}
    %>
    
  3. Start Jaggery server and go to: localhost:9763/sodbmysql/sodb.jag.
    Go to MySQL console> database sodb and enter this to view the table: mysql> show tables;.

    To insert the data from Jaggery application, change query to insert data to table:
    var query1 ="INSERT INTO example (name, age) VALUES('Jad','34');".

    To print in jaggery page, use:

    var query1 = "SELECT * FROM example;" 
    

    or:

    var results = db.query(query3);
    print(results);
    

** For more information, check this link.

6

solved Session Management in Jaggery.js [closed]