Skip to main content
Participating Frequently
August 2, 2008
Question

Cannot connect to MySQL database

  • August 2, 2008
  • 6 replies
  • 13060 views
Hi

I'm new to flex builder 3... and have therefore looked at lynda.com to learn about the product and get started fast. And here they show you how to create a connection to a MySQL database using MAMP on a mac (or WAMP on the PC) - I'm on the mac ;-).

I have installed the MAMP server with both MySQL, Apache and PHP running on defalt ports. And I have created a simple database in MySQL... The site is running fine and so is the MySQL (I have tested with simple HTML etc)... but when I try to connect to the database using the wizard in Flex, I get the following message:

Unable to connect to the database....

If I look at the details it say (hold on):
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.NoRouteToHostException: No route to host

STACKTRACE:

java.net.SocketException: java.net.NoRouteToHostException: No route to host
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at org.eclipse.datatools.connectivity.db.generic.JDBCConnection.createConnection(JDBCConnection.java:87)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:104)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:53)
at org.eclipse.datatools.connectivity.db.generic.JDBCConnectionFactory.createConnection(JDBCConnectionFactory.java:52)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:77)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:354)
at com.adobe.datatools.derived.wizards.BaseConnectionProfilePage.testConnectionSimple(BaseConnectionProfilePage.java:70)
at com.adobe.datatools.derived.wizards.BaseConnectionProfilePage.testConnection(BaseConnectionProfilePage.java:51)
at org.eclipse.datatools.connectivity.ui.wizards.ConnectionProfileDetailsPage$1.widgetSelected(ConnectionProfileDetailsPage.java:85)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1495)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1519)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1504)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1295)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3350)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2954)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at com.adobe.flexbuilder.dbwizard.ui.DbWizard$8.widgetSelected(DbWizard.java:598)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1495)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1519)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1504)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1295)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3350)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2954)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at com.adobe.flexbuilder.dbwizard.actions.DBWizardAction.run(DBWizardAction.java:69)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:256)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1495)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1519)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1504)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1295)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3350)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2954)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.adobe.flexbuilder.standalone.FlexBuilderApplication.start(FlexBuilderApplication.java:112)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)


** END NESTED EXCEPTION **

.... and more ...


..?????

What the h.. does that mean - Plz advice someoone ... I'm really stock here ;-(

Kind regards
Brian



    This topic has been closed for replies.

    6 replies

    Brian1961Author
    Participating Frequently
    August 26, 2008
    I have tjecked the Firewall settings, and all incoming connections are accepted...

    I ran the script again but same result

    If I go to MAMP startpage all is running fine and they write:
    Welcome to MAMP
    If you can see this page, MAMP is installed on your Mac and everything is working!

    To see the PHP configuration, you can watch the output of phpinfo.

    Here you can manage eAccelerator.

    The MySQL Database can be administrated with phpMyAdmin.

    To connect to the MySQL Server from your own scripts use the following connection parameters:

    Host: localhost
    [Port: 8889]
    User: root
    Password: root

    again if I try to click on phpMyAdmin I see the databases and I can edit them, so all seems fine here too

    ;-( Brian
    Participating Frequently
    August 25, 2008
    A long list is OK, since this forces the browser to not close the connection.

    Regarding the ports: Hm, at this point I can't assist. If the test app doesn't find any local MySQLserer, I suppose no server is running.

    One last try: Open System Preferences > Security > Firewall.

    Set 'Accept all incoming connections' and run the script again.

    Any changes?
    Participating Frequently
    August 24, 2008
    Please of Utilities > Network Utility and click on the 'Portscan' tab. Change the lower port number to 1, the higher port number to 2000 and enter localhost as the host-name/address.

    Portscan will spit out a list of ports on which processes are listening.

    You might or might not see MySQL behind found port numbers: Portscan prints well known name of portnumber, but not the actual protocol/application.

    Anyway, this should help finding out, what's really going on.

    In case this is of interest, we might establish a Teamviewer [ http://www.teamviewer.com/ session tomorrow. I'm happy to have a look at your config.
    Participating Frequently
    August 6, 2008
    Please post your exact JDBC connection string.

    In general, the connection wizard works well wit MAMP, XAMPP or pure MySQL on a local or remote server.
    Inspiring
    August 6, 2008
    That's good to hear but I'll be ... if I know where to find the JDBC connection string :-)
    Participating Frequently
    August 2, 2008
    Again: drop to a command line (Terminal) and give the netstat command I gave above. If you aren't able to interpret it from what I wrote above, post the results here.
    Inspiring
    August 2, 2008
    With (a standard installation of) MAMP, MySQL is on port 8889. I'm not quit sure about that wizard 'Data' in Flexbuilder, but most of the time such wizards need to know where MySQL is and since there is also a default installation of MySQL on the Mac itself.... confusion. If possible within a configuration I point to the socket of the MAMP installation (/Applications/MAMP/tmp/mysql/mysql.sock) and in other cases setting the port to 8889 helps.

    Very annoying that lynda.com doesn't seem to address this in the tutorial.
    Participating Frequently
    August 2, 2008
    quote:

    No route to host
    That's a low-level TCP/IP error message meaning that you tried to connect to an IP address that the stack has no way of finding. Although it can mean the IP is on some entirely different private network that your computer doesn't know how to get to, it usually means you've given it an address that is legal for your LAN but which doesn't actually correspond to a real machine, so the low-level protocols like ARP are failing.

    The first thing to look at is to make sure MySQL is actually listening for TCP/IP connections, and if so, on what address. It can instead accept them over Unix domain sockets, which are more secure and faster than TCP/IP, but it only works within a single computer. It's common to configure MySQL to not listen for TCP/IP connections if only local programs will access the DB. So, drop to a command line, and say:

    quote:

    netstat -na | grep 3306
    3306 is the default TCP/IP port for MySQL. If you get nothing, the MySQL server is not listening for TCP/IP connections at all. Assuming it is running, that means it's probably only listening for connections on the Unix domain socket.

    You might instead see that it's only listening on some specific IP address rather than "any" (0.0.0.0) address, so you have to use that IP to talk to the DB.

    If you find out that it should be accepting TCP/IP connections and you find the right address, try connecting from the command line using the mysql program:

    quote:

    mysql -u my_db_user -h my.server.ip -p MY_DB_NAME
    Brian1961Author
    Participating Frequently
    August 2, 2008
    Wow... thanks for the answer, but to be honest I'm still lost ...

    The IP issue you talk about ... where does this come from as we are still only on the same mashine - I use localhost ? On IP at all

    All other settings are also the standard ones so far ... you know "root" as user and so on ....

    MySQL port is 3306 and the Apache server is using port 80 (default)

    So plz explain what as I'm a newbee on MySQL and Flex

    As mentioned I use MAMP a my local server and maybe the problem is here, as I can seem to connect to it using Dreamweaver too ;-(

    Kind regards
    Brian