What is it?

P5H2 is a library for Processing (P5) the enables the easy use of the ingenious database engine H2.

The beauty of H2 is that is a java base database engine that you can distrubute and start with your script. It also include an administration interface with which you can view and change the contents of your database.
H2 Admin Interface

Install

Example

	import com.algodes.processing.*;
	
	String table    = "test";
	
	void setup(){
	
	  H2DB h2 = new H2DB(this);
	
	  h2.execute("DROP TABLE IF EXISTS " + table + ";");
	
	  h2.execute( "CREATE TABLE " + table + " ("+
		"id INT NOT NULL IDENTITY,"+
		"word VARCHAR( 255 ),"+
		"value INTEGER," + 
		"PRIMARY KEY (id)"+
		")"
		);
	
	  println("insert");
	  h2.execute( "INSERT INTO " + table + " (id, word, value) VALUES (NULL, 'one', 1)" );
	  h2.execute( "INSERT INTO " + table + " (id, word, value) VALUES (NULL, 'Two', 2)" );
	  h2.execute( "INSERT INTO " + table + " (id, word, value) VALUES (NULL, 'three', 3)" );
	
	  println("select");
	  h2.executeQuery( "SELECT * FROM "+table+"" );
	  
	  println("print results");
	  while(h2.next()){
		println(h2.getInt("value"));
	  }
	}

		

FAQ