AIR SQL Framework

When working with the Adobe AIR SQL API it is important to consider the various best practices advocated by Adobe regarding performance, security and design. As there is nothing in particular in the SQL API itself to guide developers in following these best practices, developers are left to implement their own solutions, which often may vary across different applications.

For instance, consider the SQLStatement class. In order to optimize performance of the execution of a statement, the statement must first be prepared (i.e. compiled), which optimizes the statement by the runtime prior to execution. Once a statement is prepared, if the text property does not change, subsequent executions of the statement will execute faster. In order to facilitate this particular optimization developers must first be aware of this best practice, then determine the appropriate way to implement a solution in order to take advantage of the advocated practice. A simple way to facilitate this is to define separate SQLStatement instances for each unique statement which is to be executed more than once, as is suggested by Adobe, and assume the text property is not to be assigned a new value. You could take this a step further as well and define a sub class of SQLStatement which enforces the text property is only assigned a value once, thus ensuring the optimization has been set. The AIR SQL Framework provides such facilities.

The AIR SQL Framework is a simple, reusable framework which facilitates advocated best practices when working with the SQL API in AIR.

At the foundation of the AIR SQL Framework sits the following packages:

  • com.ericfeminella.sql The sql package contains a PreparedStatement class for enforcing a SQLStatement instance to only have a text value assigned during instantiation. In addition the sql package contains an ISQLStatementCache interface which can be used to indicate an implementing class is to serve as a repository of reusable PreparedStatement instances.
  • com.ericfeminella.sql.dao The DAO package provides abstractions for both synchronous and asynchronous SQL DAO implementations.
  • com.ericfeminella.sql.utils The utils package provides helper classes for substituting statement parameters and retrieving shared SQLConnection instances

This distribution of the AIR SQL Framework should be considered an alpha release as there are some additional features which I am planning to implement, namely, the addition of support for named parameter substitutions in the SQLStatementHelper class.

I have provided an example project which demonstrates a simple AIR application built utilizing the AIR SQL Framework, along with the source, binary and documentation.

AIRSQL 0.9.1

{ 6 comments to read ... please submit one more! }

  1. Will you be creating Cairngorm services for this framework?

  2. Hey Lee,

    Yes, I do plan to create a Service which wraps these APIs as well as extend ServiceLocator so that the services can be referenced.

    Stay tuned.


  3. Sry, but after importing the zip-File into FlexBuilder 3, this msg shows up :

    Process terminated without establishing connection to debugger.


    “/Applications/Adobe Flex Builder 3/sdks/3.2.0/bin/adl” -runtime “/Applications/Adobe Flex Builder 3/sdks/3.2.0/runtimes/air/mac” “/Users/asc/Documents/Flex Builder 3/AIRSQLExample/bin-debug/AIRSQLExample-app.xml” “/Users/asc/Documents/Flex Builder 3/AIRSQLExample/bin-debug”

    Output from command:

    error while loading initial content

    What’s going wrong here ?

    Greets andreas

  4. Try creating a new project in Flex Builder, and then manually add the files. I have not seen this error before.

  5. You mentioned above about creating a service locator so that a person can use a Cairngorm style of MVC inside of AIR. Any traction on that?

{ 0 Pingbacks/Trackbacks }