nce in a while something comes along that is so simple, so straightforward, and so obvious that it's amazing that nobody did it long ago. Take blogging, for example: People have been putting their thoughts into various media for a long time, certainly long before the Web. Give someone the facility to easily put their thoughts online, with a mechanism in RSS that standardizes the format and allows others to access it, and you have a facility to publish your thoughts to the whole world. And thus blogs were born.
JoSQL is like that. But before we get into why, there's one thing that should be cleared up. Despite the name, JoSQL isn't a database server, or a toolkit for database access via JDBC, or anything like that. It's an engine that gives you to access your in-memory objects using SQL. Now, while that doesn't have the mass market appeal of blogs, to a developer it is such an amazingly useful tool that after using it, you'll wonder how high-level computing languages such as C# or Java have been around so long without this facility.
To recap: It's an engine that allows you to use SQL syntax to access your in-memory objects, so, you could, for example, do something like this:
SELECT * from com.devx.mywidgets WHERE text='hello'
This code would operate on your collection of 'mywidgets' and return a resultset that references each instance where the text property is 'hello'.
Think about how useful this can be to your applications. What if you want to skin an application by setting the color property of all your labels to one color and your panels to another color? You can run a query, pull your labels, set their color, run another query, pull your panels, and set their color. Very simple.
Alternatively, how about an application that has a number of objects in memory that represent connected clients, such as what you might find in a chat server? To perform a function such as, 'Find all clients on my server that are administrators and send them the message x,' you would have to iterate through each client, check its permissioning bits, and if they match the administrative patterns, you send them the message. JoSQL may not be more efficient than this, but it does make your code a lot cleaner.
In the following sections I'll walk you through some examples showing how it works and how it can be used in such a scenario.
Getting Started with JoSQL
JoSQL is an open source project that may be downloaded here. At this site, you'll also find some documentation and examples of how to use it. I found these examples to be a little too light and too high level, leaving you with a lot of figuring left to do (albeit with the aid of the excellent JavaDocs). Despite this, if you use a good IDE that has auto-complete then you can generally figure out a lot of the API for yourself.
To get started, download the JoSQL package and copy the JARS to a library directory. There are two JARs that you need: the JoSQL one (presently called JoSQL1-1.jar) and a third-party dependency called gentlyWeb utilities (gentlyWEB-utils-1.1.jar).
Then, from your Java code, add an import to reference JoSQL like this:
And you're ready to go.