How do I access a database directly from Flex?
This question came from a reader with no name.
I want to use the remote connection in adobe air (Action Script) to connect the database ( oracle, SQL Server etc...)
My short is answer is that you can't do this.
For a longer answer, Most people use some form of middleware; such as ColdFusion, Java, PHP, Ruby, etc... .
So, build a service in your language of choice to access the database; then use RemoteObject from your AIR app to access those services. I'm not sure if AIR will have crossdomain.xml issues or not.
There was an open source project around at one point which used sockets in the Flash player to run SQL directly against a database. I never got the impression it was production ready, though. And I can't find it in Google right now.
I love the questions that are easy to answer. Do you have one to ask me?





(kidding)
On a more serious note (it can only get more serious from there), in working with Flex on a somewhat larger scale recently, we (developers here at MediFit) have found that the less logic you make Flex do, and the more you push that off onto the server, the happier your life will be! I can only assume the same for AIR (will find out soon)
Pretty cool; I don't think I knew that.
Whether this is a good idea or not is open to discussion, I suppose.
That is exactly the project I was thinking of; thanks!
Andrew,
Thanks for the clarification on cross domain issues. I should have known that.
If you're passing URL Queries to a middleware template (Such as a CFM page), that page can deal with validating the URL data to avoid SQL injection attacks.
I'm not too knowledgeable about calling SQL procedures / statements direct on the database via HTTP protocols, though. I can see how that could cause problem if no way to validate the data to protect the injection attacks.
http://code.google.com/p/assql/source/browse/trunk...
That was in fact the project I was referring to in my post, and was linked to by William (another commenter).
I have the impression that SQL project was not production ready. I'm not sure I'd recommend using that in a production environment for that reason.
You need to use a middleware.
Try this one for rubyonrails: http://www.adobe.com/devnet/flex/articles/flex2_ra...