Friday, December 28, 2012

NoSQLite4j - Really light NoSQL database

Introducing NoSQLite4j

NoSQLite4j offers a really lite JSON based database. It is really easy to bundle with various projects. Has only dependency of java-json.jar.

It can be found here

It is really easy to implement.

Scanning the table;

import java.io.IOException;

import org.nosqlite4j.core.dml.Scan;

public class TestScan {
    public static void main(String [] args) throws IOException, NullPointerException
    {
        try{
        Scan table = new Scan("Shop");
        System.out.println(table.scan());
        System.out.println(table.getRowCount());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
      
    }
}

CRUD operations

//put

import java.io.IOException;

import org.nosqlite4j.core.dml.Put;

public class TestPut {
    public static void main(String [] args) throws IOException, NullPointerException
    {
        try{
        Put table = new Put("Shop","user2","shopped1","date1","article5");
        table.add();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
      
    }

}

//get

import java.io.IOException;

import org.nosqlite4j.core.dml.Get;

public class TestGet {
    public static void main(String [] args) throws IOException, NullPointerException
    {
        try{
       
        Get table = new Get("Shop6","user2","shopped10","date1");
        System.out.println(table.get());
        Get table2 = new Get("shop2","user2","shopped");
        System.out.println(table2.get());
   
        Get table3 = new Get("Shop3","user2");
        System.out.println(table3.get());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
       
    }
}

No comments:

Post a Comment