6 Replies Latest reply on Oct 9, 2008 5:22 AM by gmurnock

    Flex + BlazeDS + ColdFusion + SQL

    Laurence MacNeill Level 1
      Ok, I'm relatively new to this whole Flex thing -- I've been through a few tutorials, written a few apps, but I'm still unclear on a few things.

      I just want to write an app that reads record(s) from an SQL database, and allows the user to modify and update those record(s). Should be extremely simple, and yet somehow it's been overly complicated by a dozen layers of (seemingly unnecessary) software.

      So here are my questions:

      #1) Why can't Flex talk to an SQL database directly? Why do I need ColdFusion for this?

      #2) What the heck is BlazeDS? (Yes, I've read the FAQ and I still don't understand why I need it.) If I'm running BlazeDS, do I really need ColdFusion? If so, why?

      #3) In the BlazeDS FAQ, it mentions something about accessing server-side Java objects -- so do I need to install JavaEE on top of CF and the SQL database now, too?

      It just seems so overly complicated for such a simple task.

      If someone could explain all this to me, I would greatly appreciate it.
        • 1. Re: Flex + BlazeDS + ColdFusion + SQL
          riesvantwisk Level 1

          1) Flex (AIR) can talk to SQLite directly and I believe there is a MySQL driver (Also air??) that can talk to MySQL directly. Other databases are not supported.
          The main reason for this is that flex (browser) needs a client/server architecture. It more or less is the same reason that javascript doesn't talk to any DB directly. And the reason is that http protocol is the 'standard' to communicate between a web-browser and a remote server, works across firewalls etc... For AIR there are simple no drivers yet, but I believe some are currently in development.

          2) If you want to use Blaze-DS then you need java on the server. Blaze-DS is your middle layer that accepts a AMF request and passes the request to a pojo. Blaze-DS makes it simple to make that middle layer you hate so much. It can do more, like sending messages to attached clients from the server.

          3) TO use Blaze-DS you can use a simple tomcat server if you want to, and I believe on the of the Blaze-DS samples even comes with tomcat.

          The whole system is not really over-complex, much of the layer are just needed with flex (Browser version) because of protocol conversions. There are currently no protocols that allows you to run SQL directly over HTTP. But also tehre are many other systems you would like to read... there are many RDBM systems OODB system, file systems etc.... These all need to get accessed by layers.

          If you run Adobe AIR then there are standard API's available taht can read a filesystem (weather it's NTFS, FAT, EXT2, EXT3 etc.. etc..) however these are not standards for SQL or other systems. So you need layers.... But like I said, Adobe AIR does come with a SQLite driver.


          May be you can explain what environment you are running?

          Ries





          • 2. Re: Flex + BlazeDS + ColdFusion + SQL
            Level 7

            "riesvantwisk" <webforumsuser@macromedia.com> wrote in message
            news:gcjgm9$hjh$1@forums.macromedia.com...
            > 1) Flex (AIR) can talk to SQLite directly and I believe there is a MySQL
            > driver (Also air??) that can talk to MySQL directly. Other databases are
            > not
            > supported.
            > The main reason for this is that flex (browser) needs a client/server
            > architecture. It more or less is the same reason that javascript doesn't
            > talk
            > to any DB directly. And the reason is that http protocol is the 'standard'
            > to
            > communicate between a web-browser and a remote server, works across
            > firewalls
            > etc... For AIR there are simple no drivers yet, but I believe some are
            > currently in development.

            You can connect directly to databases using a socket. However, this
            requires the cooperation of the server involved. Any AIR drivers will need
            to access a socket, which means that some sort of server must be installed
            and running on the machine that hosts the database. When AIR talks to
            SQLLite, this is a database that is stored locally on the machine and is
            quasi integrated into AIR itself.

            > 2) If you want to use Blaze-DS then you need java on the server. Blaze-DS
            > is
            > your middle layer that accepts a AMF request and passes the request to a
            > pojo.
            > Blaze-DS makes it simple to make that middle layer you hate so much. It
            > can do
            > more, like sending messages to attached clients from the server.
            >
            > 3) TO use Blaze-DS you can use a simple tomcat server if you want to, and
            > I
            > believe on the of the Blaze-DS samples even comes with tomcat.
            >
            > The whole system is not really over-complex, much of the layer are just
            > needed
            > with flex (Browser version) because of protocol conversions. There are
            > currently no protocols that allows you to run SQL directly over HTTP. But
            > also
            > tehre are many other systems you would like to read... there are many RDBM
            > systems OODB system, file systems etc.... These all need to get accessed
            > by
            > layers.

            Actually, if you're using MDAC on Windows there are drivers that will let
            you plug directly into, for instance, SQL Server or mySQL on a server.
            However, you can't use MDAC from a swf or from AIR because (a) a swf
            wouldn't have permissions to do so and (b) this is Windows-only
            functionality based on dlls, so even AIR doesn't allow it. It is very
            unusual, however, for developers to use this sort of thing to plug directly
            into a database. The more accepted method is to use a back-end page that
            has full read, write, execute privileges on the database to do this.

            Hope this clarifies;

            Amy


            • 3. Re: Flex + BlazeDS + ColdFusion + SQL
              riesvantwisk Level 1
              @ALL,

              this project might help if you are a MySQL fan : http://code.google.com/p/assql/

              If believe that some guy was checking for a PostgreSQL driver aswell (would be awesome).

              Of-course you can use a socked to connect any service, but that means you need to handle the protocol your self which is not easy...

              Ries
              • 4. Re: Flex + BlazeDS + ColdFusion + SQL
                Laurence MacNeill Level 1
                quote:

                Originally posted by: riesvantwisk

                1) Flex (AIR) can talk to SQLite directly and I believe there is a MySQL driver (Also air??) that can talk to MySQL directly. Other databases are not supported.
                The main reason for this is that flex (browser) needs a client/server architecture. It more or less is the same reason that javascript doesn't talk to any DB directly. And the reason is that http protocol is the 'standard' to communicate between a web-browser and a remote server, works across firewalls etc... For AIR there are simple no drivers yet, but I believe some are currently in development.

                Ok, so basically if I want web functionality in my Flex app, I have to use CF because HTTP breaks the direct connection between the Flex app and the SQL database. Fine...



                quote:

                2) If you want to use Blaze-DS then you need java on the server. Blaze-DS is your middle layer that accepts a AMF request and passes the request to a pojo. Blaze-DS makes it simple to make that middle layer you hate so much. It can do more, like sending messages to attached clients from the server.

                Got no idea what a 'pojo' is. Or really what an AMF request is. I know AMF has something to do with remote-control of clients, or something like that?



                quote:

                3) TO use Blaze-DS you can use a simple tomcat server if you want to, and I believe on the of the Blaze-DS samples even comes with tomcat.

                Got no idea what a 'Tomcat server' is either. Never even heard of it.



                quote:

                The whole system is not really over-complex ... <SNIP> ... May be you can explain what environment you are running?

                Yeah, I'll need my app to run in both a web-browser and on a desktop. It's the main reason I chose Flex, since it's just a simple re-compile to go from web to desktop (as long as I'm not interested in Air-specific local-filesystem calls, which I'm not because all our data is going to be stored on the web server.) Technically I could run everything through a Flash-equipped web-browser -- but why bother with using a web-browser on local intranet machines? Just takes up extra bandwidth on the local network. So we'll run the app in Air on local machines, and customers will run it through their Flash-equipped web-browsers on their home machines.

                But I still don't get why BlazeDS is needed. What does it do, exactly? And how hard is it to set up all the J2EE and Tomcat stuff (whatever the heck Tomcat is) before you're able to run BlazeDS? It just seems like such a hassle. (Heck, CF is enough of a hassle -- I can't even get that to install without killing IIS...)
                • 5. Re: Flex + BlazeDS + ColdFusion + SQL
                  Level 7

                  "Laurence MacNeill" <webforumsuser@macromedia.com> wrote in message
                  news:gcjrqu$1mk$1@forums.macromedia.com...
                  >
                  quote:

                  Originally posted by: riesvantwisk
                  >
                  > 1) Flex (AIR) can talk to SQLite directly and I believe there is a MySQL
                  > driver (Also air??) that can talk to MySQL directly. Other databases are
                  > not
                  > supported.
                  > The main reason for this is that flex (browser) needs a client/server
                  > architecture. It more or less is the same reason that javascript doesn't
                  > talk
                  > to any DB directly. And the reason is that http protocol is the 'standard'
                  > to
                  > communicate between a web-browser and a remote server, works across
                  > firewalls
                  > etc... For AIR there are simple no drivers yet, but I believe some are
                  > currently in development.

                  > Ok, so basically if I want web functionality in my Flex app, I have to use
                  > CF
                  > because HTTP breaks the direct connection between the Flex app and the SQL
                  > database. Fine...
                  >
                  >
                  >
                  >
                  quote:

                  2) If you want to use Blaze-DS then you need java on the server.
                  > Blaze-DS
                  > is your middle layer that accepts a AMF request and passes the request to
                  > a
                  > pojo. Blaze-DS makes it simple to make that middle layer you hate so much.
                  > It
                  > can do more, like sending messages to attached clients from the
                  > server.

                  > Got no idea what a 'pojo' is. Or really what an AMF request is. I know
                  > AMF
                  > has something to do with remote-control of clients, or something like
                  > that?
                  >
                  >
                  >
                  >
                  quote:

                  3) TO use Blaze-DS you can use a simple tomcat server if you want to,
                  > and I
                  > believe on the of the Blaze-DS samples even comes with tomcat.

                  > Got no idea what a 'Tomcat server' is either. Never even heard of it.
                  >
                  >
                  >
                  >
                  quote:

                  The whole system is not really over-complex ... <SNIP> ... May be you
                  > can
                  > explain what environment you are running?

                  > Yeah, I'll need my app to run in both a web-browser and on a desktop.
                  > It's
                  > the main reason I chose Flex, since it's just a simple re-compile to go
                  > from
                  > web to desktop (as long as I'm not interested in Air-specific
                  > local-filesystem
                  > calls, which I'm not because all our data is going to be stored on the web
                  > server.) Technically I could run everything through a Flash-equipped
                  > web-browser -- but why bother with using a web-browser on local intranet
                  > machines? Just takes up extra bandwidth on the local network. So we'll
                  > run
                  > the app in Air on local machines, and customers will run it through their
                  > Flash-equipped web-browsers on their home machines.
                  >
                  > But I still don't get why BlazeDS is needed. What does it do, exactly?
                  > And
                  > how hard is it to set up all the J2EE and Tomcat stuff (whatever the heck
                  > Tomcat is) before you're able to run BlazeDS? It just seems like such a
                  > hassle. (Heck, CF is enough of a hassle -- I can't even get that to
                  > install
                  > without killing IIS...)

                  BlazeDS handles all the messaging for you. If you don't need your apps to
                  be informed of stuff without making server request, you can use literally
                  any back end under the sun, ASP, PHP, even good ole CGI.


                  • 6. Re: Flex + BlazeDS + ColdFusion + SQL
                    gmurnock Level 1
                    Laurence - you are already using CF (7.02 at least I hope) so you do not need BlazeDS, unless as stated above, you need your connected users to be notified of changes on the fly (data pushed to them). You also do not need Tomcat as CF has your server built in. So with the software you have stated (Flex Framework, CF, SQL Server) is basicly all you need. If using Flex Builder I suggest intalling the CFEclipse plugin (from CFEclipse.org) to edit your .cfc "pages", aka all of your middle tier functionality others have memtioned PHP, ASP, CGI. If your ColdFusion is all set up with the database connections in place you can use the wonderful wizards in Flex to create working items. I don't suggest it for longer term development, I feel there is way too much overhead code in the wizars but that is IMHO. Getting back to subject... Flash Builder 3, CF7.02, SQLServer and you have everything you need to get going on it.
                    Greg Murnock