Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

UrSQL: Data Storage for JavaUrSQL is a persistent storage API for Java Desktop Applications. Unlike other SQL variants, UrSQL doesn't require any kind of server or driver. It's usage is as simple as storing data should be. Loading a database file is as easy as UrSQLController ... [More] controller = new UrSQLController("database.udb");Writing Data to the DatabaseUrSQL stores entries as key value pairs. Groups of entries are called entities, each with a unique numerical ID. To create a new entity, which will store key-value entries: UrSQLEntity entity = controller.createEntity();Now, we can create a new entry: UrSQLEntry entry = new UrSQLEntry("key", "value");This entry now has the key/value pair "key: value". However, we have not specified what entity it belongs to yet. To do so: entity.addEntry(entry);Now, we can write our entry to the database: controller.writeEntry(entry);We could also write the entire entity to the database: controller.writeEntity(entity);Reading Data From the DatabaseUrSQL can search its database for particular entities and entries based on queries containing key/value pairs. For example, the following finds the entity where "key1" has a value of "value1" and "key2" has a value of "value2": UrSQLEntity entity = controller.getEntity("key1: value1; key2: value2");Notice that the colon (:) is used to separate keys and values, and the semi-colon (;) is used to separate key/value pairs. The spaces after the colon and semicolon are not necessary, but make the code a bit easier to read. Now, you can access individual entries from the entity with their key names: UrSQLEntry entry = entity.getEntry("key1");The entry object contains the entry's key and value, which can be accessed with: String key = entry.getKey(); String value = entry.getValue();Or, if you don't want to access an entire entity, you can also access a single entry using a query. This query uses known values in the same entity to search out the correct entry within the correct entity. For example, if we know that an entry with the key "key1" is contained in the same entity as an entry with the key "key2" and value "value2", then we can use the following: UrSQLEntry entry = controller.getEntry("key1", "key2: value2");Or, the second argument can be the actual UrSQLEntity that houses the desired entry. The entry can then be accessed and changed accordingly. Remember no data is actually written to the database until writeEntry or writeEntity is called by the controller object. [Less]

0
 
  0 reviews  |  0 users  |  1,278 lines of code  |  0 current contributors  |  Analyzed 3 days ago
 
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.