1 person found this helpful
Flex takes care of the client-side so it has no "easy way of connection to a database". Reading, modifying and adding data to and from a database is achieved with the help of a server-side script ( like PHP, ASP.NET, CF and so on ). You'll have these server-side scripts that you can call from Flex ( by sending requests ), once the script finished the parsing or editing, it can send a response back to Flex, signaling if the action has finished successfully ( obviously, it can also send data to Flex ).p
Usually, the data sent back to your Flex application is of XML structure since parsing XML is quite easy with ActionScript 3.0. So, this is how you'd do it with Flex in a web application. If you are aiming for desktop applications, then AIR has additional features that can help you connect to certain databases and modify them directly ( usually SQLite databases ).
You'll find more detailed information in the Adobe LiveDocs.
EDIT: There would be a more "direct way" to connect to a database directly but for that you'll need to work with sockets ( which isn't really clean or secure but it can be done if you really don't want to touch any server-side technologies that would handle the basic CRUD operations ).
1 person found this helpful
Here are some great tutorials on using Flex and PHP to connect to a MySQL database and add and modify data.
If this post answered your question or helped, please mark it as such.
Regarding the sockets: Yes, I understand and did signif socket coding in days of yore, but been there, done that, got that t-shirt...and it's a lot of grunt work, so why re-invent that wheel? I need a simpler solution, if its available.
Regarding the PHP solution. How much grunt work is involved? I know java, JSP and JSF, but not PHP. I have a java (probably JSP or servlet) solution coming in a book I bought, but it doesn't look as simple as a VB solution would be.
It appears to me that everybody (the users of the world) continue to want what they had with VB, Delphi, etc, but they now want it all web-enabled naturally. Thus the advent of ajax, flex, silverlight, etc. to try to fill that desire: drag/drop, asynch data-push onto the browser, and other such non-request-response-based functionality that is just not possible without some kind of client-side scripting.
It is only logical then that flex or silverlight (or some new kid on the block) will come up with a simple (or at least simpler) database access model, as it is currently a major missing piece of the puzzle...unless, of course I'm missing something fundamental, and the server code can't be auto-generated for some tech reason I'm not aware of. I'm betting it can. I'm betting it can be auto-generated.
Flex would certainly raise the bar for Silverlight to have to jump, if it (Adobe) could implement it first.
But thanks. I'll use the PHP solution(s) you suggest as a plan B if the book's java-based solution doesn't work out for me.
Message was edited by: benethridge
I did not know more clearly about it but I agree it with you. believe in yourself
In my opinion, each technology has it's role. Nor Flash or Flex were conceived with the idea of "it should be able to handle anything on it's own". Both technologies were designed for the client side and they do an awesome job on the client side. I don't think that Adobe should invest in adding support for direct database access and who knows what that normally, would involve the use of a server-side script that was invented for that exact purpose ( like PHP, ASP.NET and so on ).
You are talking about "basic CRUD", but ok, if they would implement support for basic CRUD, don't you think that people would come whining with "and there's no security? how can I stop people from messing up my applications"? So CRUD would also involve other things without which having that "basic CRUD" is quite senseless... more "things" involve more money, more people, more time and so on.
In the end, no one is forcing no one to use a certain technology. This is what Flex can offer, if someone is not pleased with it, then simply change to something else. I believe that it's good the way it is and instead of investing in such features, they should focus on making the current features run better and faster ( especially the compiler ).
Just my 2 cents.
I don't necessarily agree with all that, but I think I understand your points, and respect your opinion on them. Thanks for taking the time to discuss this one.
Not sure if this will help others but I have found a possible answer or at least a possible direction from Adobe, poking around on google:
The above shows how to generate a "J2EE database application", using the Flex/Eclipse menu Data -> Create Application From Database
This is somewhat primitive (or else I'm missing something) in that it only creates one table of a database, and appears to use one connection for each coumn in the table. (Elegant would be that it creates the whole database, not just one table, of course, and only connects once to the database.)
It also has a couple of bugs, I think:
1. You have to specifiy your server's hard IP address 127.0.0.1, instead of localhost, when you create the database connection to MySql. (I think this is a bug in the Flex IDE or maybe Eclipse in general, not in just in this particular menu item wizard. Sql Explorer in Eclipse has this same problem.)
2. When generating the java code and ActionScript and .mxml (i.e. the Flex "application"), it returns a popup box with a NullPointerException, but doesn't give you a clue as to why that occurred. (Typical with these wizards.)
Bugs notwithstanding, this process generates a LOT of files, i.e. looks like it's truly trying to generate an entire Flex application, so I'm thinking this one has a lot of potential. It also looks like it has support for LiveCycle in addition to the option I selected: XML over http.
Does someone know the workaround to the bug? Is this the future direction for Adobe, or am I barking up a dying tree?
Using the Remote Object (or) Http Service we can easily access database from easily.
I looked over this php solution. It looks good and thanks for that.
However, it led me to Groovy On Grails (now a part of Spring), which looks fantastic. I love the "Convention Over Configuration" aka the "Coding By Convention" - see here: http://en.wikipedia.org/wiki/Grails_(framework) ...and the associated DRY ("Don't Repeat Yourself") concept implemented by "closures". See here: http://en.wikipedia.org/wiki/Don%27t_repeat_yourself
Any samples or tutorials of Flex integrating with Groovy/Grails?
I am trying to create a simple CRUD DB Flex application with FlashBuilder4 beta and BlazeDS4 beta.
Under Data there is no more item "Create Application from Database", so I am using "Connect to Data/Service" (or "Connect to BlazeDS")
I am using Turnkey, so selected "No Password".
It immediately shows an error: "Connect to Data/Service"
What should I do ? Any dflt login/pwd for turnkey BlazeDS ?
If I need to use PostgreSQL DB, all I need is just type 4 JDBC driver, no special "support" for it, correct ?
Can I assume that BlazeDS is sufficient to create DB CRUD app or does it require LCDS (e.g. Data Management services) ?
Any good pointers/docs (for either Flex3 or Flex4) ?
I don't know yet. I'm putting my CRUD together with two good books:
Hibernate Made Easy - by Cameron McKenzie and
Adobe Flex 3 Training From The Source - by Tapper et al.
I'm using a java web service on the backend (based on these books).
I'm using JBoss app server, not BlazeDS.
I also use JBoss, ver. 5. Tomcat only for initial CRUD try (on BlazeDS Turnkey).
BlazeDS is NOT an app server, but an open source version of LCDS (which doesn't have many of its features,
like Data Management Services and Synchronization).
Is generated code in Hibernate ?
I also have the same Flex book (will check it for CRUD).
I should mention that I do not use PHP or ColdFusion.
Any advice, guys ?
I'm not sure the Flex book talks about CRUD. The Hibernate book does, though.
No, the code is NOT generated in Hibernate. I write it all by hand. I
have been generating the database tables from Hibernate lately,
though. (Before that, I was hand-creating both the database tables and
the Hibernate POJOs.)
Once I have the web service, it's pretty easy to see (using the Flex
book) how to get it into Flex (using xml).
Yes, that Flex book talks about CRUD a little bit (Data Wizards, ppg. 492-497)
There are other possibilities with CRUD, like open-source Eclipse plugin ClearDataBuilder (works with SQL or DTO, for LCDS or BlazeDS),
I know people who use it in production, but do not have any serious experience with it.
Anybody: how does it work for you ? Is it better than FB3/FB4 CRUD generators?
Also, there is a Hibernate Assembler in LCDS.
1. Where you able to resolve that NullPointerException during "Create Application from Database" process ?
I ran into the same problem and got stuck !
2. I tried to do CRUD using ClearDataBuilder, but ran into another error:
C:\workspace1\CRUD2\daoflex.build\daoflex-build.xml:99: Error starting modern compiler
That seems to be a popular Ant/Eclipse problem, which is caused by JAVA_HOME being different
from Eclipse JavaVM, but in my case all of them are pointing to the same JDK 1.6.0_16.
Please help !
No, I just grunted it out in a java web service.
It seems that problem #1 (NullPointerException in "Create app from Database in FB3") is very common,
there are several tickets open in Flex Bugs database.
But... Adobe closed them with "Use FlashBuilder 4 wizard instead" comment.
On is outstanding with "Community" status - how can Community fix FB bugs ?!!
I see it as a showstopper for CRUD.
Since FB4 is in beta for at least till mid February or March, how can one use it, especially in production ?
And who knows how long will it take to become accepted by Flex Community.
I am frustrated with Adobe !
As far as problem #2, I am still getting that dreaded "Error starting modern compiler" error.
Any idea how to fix that ?