7 Replies Latest reply on Feb 18, 2008 6:35 AM by Bill Sawyer

    Unable to connect to the database

    Bill Sawyer Level 1
      I am using Version 3.0 (build 3.0.190133beta3) on Windows XP Profession SP 2+

      I created a Project with PHP as the server type. I then did the following steps:

      1) Menu > Data > Create Application from Database
      2) Click NEW... on the Connection field.
      3) Put in a Name (Test).
      4) Click the Next button.
      5) Set the Host URL, Database Name, User Name and Password as appropriate.

      How do I know they are appropriate. If I go into Dreamweaver CS3, create a recordset, and a new connection. And, I input exactly the same connection info into DW, and click the TEST button, it works.

      6) Click the Test Connection button.
      7) Connection fails with the following error:

      Unable to connect to the database.

      The DETAILS are attached as code to this message.

      I am not sure what I am doing wrong. But, something is not working.

      Regards,
      Bill Sawyer
        • 1. Re: Unable to connect to the database
          Bill Sawyer Level 1
          I logged a bug for this when I reproduced it 2nd and 3rd machines on different networks.

          https://bugs.adobe.com/jira/browse/FB-12094

          Regards,
          Bill
          • 2. Re: Unable to connect to the database
            mcaudy
            Bill,
            I have successfully connected to a MySQL DB from Flex Builder 3 using the same general approach you did, but with the following additoins:

            1) you have to get your DB connection working. This will create a connection file in you Flex project folder with a name that end in xxxconn.php, and the contents will look something like: (The xxx is basically whatever you named that project).

            <?php
            /**
            * connection settings
            * replace with your own hostname, database, username and password
            */
            $hostname_conn = "localhost";
            $database_conn = "your_dbname";
            $username_conn = "root";
            $password_conn = "your_rootpassword";
            $conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
            mysql_select_db($database_conn, $conn);
            mysql_query("SET NAMES 'utf8'");
            ?>

            This is your connection file, and is needed to connect to your DB.

            Once this is accomplished, there are several additional steps you must follow. These are outline in this info that I found on the web. Here is the overall procedure:

            To create a new Flex application that is connected to an online database:
            Create a new Flex project.
            Select PHP as the application server type.
            Set the webroot folder, and the Root URL to your web root. (where your PHP files run from.)
            Click on validate configuration. (This must be working)
            Click on Finish.
            In Flex Builder, select the Data menu, and then Create Application from Database…
            Select the project you just created. (click on the xxx.mxml file in your new project)
            Create a new database connection. Give it any name. Click next.
            Enter the host URL, database name, username and password for your MySQL
            installation. Click Test Connection to make sure everything is OK. (This also must be working)
            Click Finish if it was OK.
            Select the desired DB table name under table, and select the column key to use as the primary key. Click next.
            Select the folder to put the generated PHP code (bin/ by default) and the file name for the
            PHP source file).
            Click next, where you can select what to show in the application. Click finish.
            Right click on the generated .mxml file and select Run the application.
            A file will open in you web browser, with access to the database table you set up in the connection settings.

            This worked for me, after some effort.

            Mike
            • 3. Re: Unable to connect to the database
              catalinanastasoaie Level 1
              Hi Bill,

              It appears that the wizard cannot access the database server. Try pinging the server before using it in order to make sure that it is working properly. The database is on an internal server? Can it be access from outside? I tried pinging the db1368.perfora.net server but I didn't received any response.

              Thanks,
              Catalin Anastasoaie
              • 4. Re: Unable to connect to the database
                Bill Sawyer Level 1
                Mike,

                I'll try that, and report back. But, the connection should still work as directed, and it doesn't.

                Bill
                • 5. Re: Unable to connect to the database
                  Bill Sawyer Level 1
                  Catalin,

                  I can go into Dreamweaver CS3, and create a connection to that machine and database just fine. It is not an internal machine. It is actually a webhosting company. I can use PHP to connect to it, just fine. Something isn't working correctly within Flex 3.

                  Regards,
                  Bill
                  • 6. Re: Unable to connect to the database
                    catalinanastasoaie Level 1
                    Bill,

                    Can you find out the IP address of the database server and try again using the IP instead of server name?

                    Thanks,
                    Catalin Anastasoaie
                    • 7. Re: Unable to connect to the database
                      Bill Sawyer Level 1
                      Catalin,

                      Good idea, but how? This is a 3rd party webhosting company. The IP name is just a place holder (probably a redirect) to a machine. But, something isn't working that works in another Adobe product.

                      If you like, send me an email directly, and I will send you all the connection information that I have, including the DB name, user, and password. If this didn't work in Dreamweaver, I would suspect a set-up issue on my part. But, this works just fine. If need be, I can even set-up a webconference on my end, and show you directly how I can connect in DW CS3.

                      Let me know how to proceed. I am glad to help in anyway I can.

                      Regards,
                      Bill