16 Replies Latest reply on Aug 16, 2007 12:49 PM by Peter Flynn (Adobe)

    create database accessor not working

    mreine
      I just installed Flex 3 beta. I used the "Create Database Accessor" to create access to my mysql database. The application with a simple table pulling in data from mysql works great when run on my local machine. When i upload the code to the same machine as the database resides on, i get an actionscript error when i try to run the code. See in action below:

      https://devel.gardenfreshcorp.com/test/bin/grid.html

      Can anyone help me? :) please....

      mysql database user has permission to access database, and i have several flex2 apps running on same machine accessing same database and it works fine. I added: -use-network=true but nothing works.

        • 1. Re: create database accessor not working
          mreine Level 1
          If this helps, i ran in debug mode and the error is stemming from the ActionScript file and this particular line:

          if (obj.data.elements("error").length() > 0)
          {
          toret.isError = true;
          toret.data = obj.data;
          }
          • 2. Re: create database accessor not working
            mreine Level 1
            https://devel.gardenfreshcorp.com/test/Grid.php?orderField=category&orderValue=ASC&method =FindAll

            If i run the php manually, it returns data so I know it can access the database. Not good coding by the way as anyone could then delete entries from my database or update without permission. Adobe should fix this.
            • 3. Re: create database accessor not working
              mreine Level 1
              ok, I might have the reason but not the solution. It appears to be returning malformed xml:

              <row>
              <category>Morn Menu</category>
              <name>Henderson</name>
              <scope>68</scope>
              <date/>
              <description>MM Start</description>
              <do>Natalie Lahr</do>
              <vp>Michael Malone</vp>
              <ck>816</ck>
              <updated>0000-00-00 00:00:00</updated>
              <completed>no</completed>
              </row>

              Notice no open <date> but only a <date/>

              Something wrong in the flex3 code it seems. Does this make sense or am i missing something?
              • 4. Re: create database accessor not working
                mreine Level 1
                Odd thing is that the same xml works find when run locally on my local machine.
                • 5. Re: create database accessor not working
                  catalinanastasoaie Level 1
                  Hi mreine,

                  The thing here could be that you have entered in the Host URL: text field localhost therefor when running the application on the online server the mysql server isn't found. Try using the IP address instead of localhost.

                  Regards,
                  Catalin Anastasoaie
                  • 6. Re: create database accessor not working
                    mreine Level 1
                    Thanks for the suggestion but I have already tried the ip address, domain name and localhost. https://devel.gardenfreshcorp.com/test/Grid.php?orderField=category&orderValue=ASC&method =FindAll

                    that is the script that it uses and it works.
                    • 7. Re: create database accessor not working
                      satishtj
                      Hi
                      XML data which has been pasted was that the copy from console of flex builder in debug mode??
                      I too had such situation .. Flex Builder truncates the display .. So dont believe that ..

                      While working with embedded databases i too encountered property name not found .

                      The problem is coz its a event based architetcure , until creation complete event is fired u should not use the object ..
                      So one has to properly place the codes in the eventHandlers ,,
                      for example here in ur example i am finding fill() being called but no guarantee the previous event has completed ..

                      When i went through this i found out that flash does not support multithreading ..
                      So here what i think is when pgm called addeventlistener listener was added ..
                      n control returned n fill() takes the control .. n the event may never fire !!

                      SO just try putting some buttons n structure the code within the handlers of these .. i think that should work

                      • 8. Re: create database accessor not working
                        metaclark
                        hello I just made a data accessor project and then when I try to make another one there is an error on flex builder and ask for leave the builder and when I say NO nothing happens.... May I create only one data accessor? I have tested this on mac and windows beta versions
                        • 9. Re: create database accessor not working
                          Peter Flynn (Adobe) Adobe Employee
                          mreine -- are you still experiencing problems? Can you give us the specific exception that's being thrown by the AS code?

                          Looking at some the specifics in your posts...
                          1. If the problem is coming from the line 'if (obj.data.elements("error").length() > 0)', this suggests there was an error on the server. A proxy tool may be helpful in debugging this, to see if the request being sent it correct, etc.
                          2. <date/> is valid XML; it means the same thing as <date></date>
                          3. You mention some security concerns about the generated PHP. The basic generated code does not include user authentication -- it's just a scaffolding for you to build upon. You'd have to add authentication to your web app on your own. I will see if we can add a comment into the generated code to remind people of this.

                          Thanks for the feedback, and I hope you're having better luck now!

                          - Peter
                          • 10. Re: create database accessor not working
                            Peter Flynn (Adobe) Adobe Employee
                            metaclark -- what did the error message say? Can you file a bug about this problem? Please attach your Eclipse log file (found at [your workspace]/.metadata/.log) to help us understand your problem.

                            Thanks!

                            - Peter
                            • 11. Re: create database accessor not working
                              catalinanastasoaie Level 1
                              Hi mreine,

                              Could you verify and make sure that the test machine has access to your mysql server? and try again to reproduce the problem?

                              Thanks,
                              -Catalin
                              • 12. Re: create database accessor not working
                                mreine Level 1
                                I can connect to mysql find on this machine. I have several other flex apps that I created and they use the same database, same login, same pass and they work fine on this same machine.

                                Only the auto generated code from flex3 does not work. It works when connecting to the database remotely but not when I copy the code to the machine. I can run the php pages and they connect and generate xml correctly. Error is here:

                                https://devel.gardenfreshcorp.com/test/bin/grid.html

                                one of the php pages it is running is here:
                                https://devel.gardenfreshcorp.com/test/Grid.php?orderField=category&orderValue=ASC&method= FindAll

                                Tryit and see. You can see that the database connection is working and the xml data is being returned.

                                The application works fine on my local system which is the strange thing and all of my flex2 apps work fine.


                                • 13. Re: create database accessor not working
                                  mreine Level 1
                                  The mysql server is on the test machine and yes, my other flex2 apps work fine with same username, pass, database, data.

                                  • 14. Re: create database accessor not working
                                    mreine Level 1
                                    Error message can be seen here:
                                    https://devel.gardenfreshcorp.com/test/bin/grid.html

                                    or below:

                                    ReferenceError: Error #1069: Property data not found on String and there is no default value.
                                    at grid/deserialize()
                                    at grid/resultHandler()
                                    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                                    at flash.events::EventDispatcher/dispatchEvent()
                                    at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
                                    at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
                                    at mx.rpc::Responder/result()
                                    at mx.rpc::AsyncRequest/acknowledge()
                                    at ::DirectHTTPMessageResponder/completeHandler()
                                    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                                    at flash.events::EventDispatcher/dispatchEvent()
                                    at flash.net::URLLoader/flash.net:URLLoader::onComplete()
                                    • 15. Re: create database accessor not working
                                      mreine Level 1
                                      http://localhost/xampp/test3/bin/grid.html I can run the app locally but connect to the remote mysql server fine.

                                      Screenshots here:

                                      https://devel.gardenfreshcorp.com/test/screenshot.jpg (running locally but connecting to devel mysql)
                                      https://devel.gardenfreshcorp.com/test/screenshot1.jpg (error box when running on devel server)
                                      https://devel.gardenfreshcorp.com/test/screenshot2.jpg (app running on devel server but after error message and no data pulled in)
                                      https://devel.gardenfreshcorp.com/test/screenshot3.jpg (php page on devel that flex3 app uses and it returns correct xml and connects to mysql fine)
                                      • 16. Re: create database accessor not working
                                        Peter Flynn (Adobe) Adobe Employee
                                        mreine,

                                        The error seems to indicate that you're getting a malformed response back from the server. There are two ways you can try to debug what that response is:

                                        1. Launch the SWF in Debug mode using Flex Builder. The first line of deserialize() -- "trace(ObjectUtil.toString(obj));" -- should print the server's response to the console.
                                        2. Use a proxy tool such as Fiddler ( http://www.fiddlertool.com) to monitor all the traffic between your SWF and the server. This way you can also examine the HTTP request for problems.

                                        Let us know if this helps at all.

                                        - Peter