Skip to Content

Some times in java programming, It is a big pain deal with Collections and Arrays, it’s not so easy getting the flexibility presented in our sql engine.
Using hsqldb open source database engine you can manage your in-memory data the same way that your persistent databases.
I prepared a small example to show this funcionality.

Create a java project.

Add hsqldb.jar in your java build path.

Try this example.

See, you can select from your in-memory table using like condition:

  customers.insert(1, “Alvaro Tejada”,”Perú”);
  customers.insert(2, “Craig Cmehil”,”Germany”);
  customers.insert(3, “Jim Spath”,”US”);
  customers.insert(4, “Mark Yolton”,”US”);
  customers.insert(5, “Mark Finnern”,”US”);
  ResultSet rs = customers.read(“WHERE name like ‘%Mark%’“);  
  while (rs.next()) {
   System.out.println(rs.getString(“id”) + “-” + rs.getString(“name”) + “-” + rs.getString(“address”));   
  }

Console output:
4-Mark Yolton-US
5-Mark Finnern-US

 

Your comments are welcome,
Thanks and Regards,
Ignacio.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Is this type of methodology available also for complex objects like locations, where coordinates are used to infer distances on road, rail and plane networks?
    (0) 

Leave a Reply