Sometimes not connecting to MySQL server

Hello. I have some features in my app where I need the user to connect to a database on a MySQL server. Some users (not many) have not been able to connect to the database. I set the db port to 3306. I’ve read online that some firewalls can block this port and would need to allow access in order to communicate with it. Is this true? Would you suggest choosing a different server port instead of 3306 that allows for easier communication and can bypass a firewall easier?

I have my generic code below (different obviously as mine has different host, username, and password). As you can see I don’t call the port here. I modeled this after the example in Xojo examples, which does not include the port in the code. If I include the mdb.Port = “3306”, would that work better for those users who aren’t able to connect?

'connect to MySQL
mDb = New MySQLCommunityServer

mdb.Host = “myDBhost”
mdb.UserName = “myDBname”
mdb.Password = “myDBpassword”
mdb.DatabaseName = “myDBname”

If mDb.Connect Then
'something happens

Else
'something else
End If

If this database is accessed by clients over the Internet rather than a LAN, the first I’d do is write PHP (or Web Edition “special” URL) wrappers for your database API. Clients would access via HTTP calls. There is one school of security that says you really don’t want database passwords distributed to direct use by client apps.

Thanks Brad. This is a new concept to me. Are there any examples you’re aware of? Would that mean that my code above for mdb would get scrapped altogether and connected via code?

I just tried throwing the host name into a browser, but it didn’t open anything

If you don’t specify the port, it uses 3306, so specifying it explicitly would not make any difference. What error messages do you get back when they can’t connect? And what kind of delay do they experience before it fails? No delay might indicate a firewall issue or the remote server is rejecting the request. Long delay means it got past the firewall but can’t talk to the mysql service for some reason.

[quote=88291:@Ryan Hartz]Thanks Brad. This is a new concept to me. Are there any examples you’re aware of? Would that mean that my code above for mdb would get scrapped altogether and connected via code?
[/quote]

Without writing a book… this link kinda shows the concept, albeit for a different technology stack:

http://www.ibm.com/developerworks/xml/library/x-javascriptdataaccess/index.html?ca=dat

Hi Tim. No error messages and no long waits that I know of. I coded so that if it doesn’t connect, the program can continue uninterrupted. The initial need was to access registration codes on the server. If not connected, I built in a back door to bypass that step and still enter the program

Brad - thanks for finding that resource. I’ll take a look at it tomorrow and see if I can make use of this

Hi Ryan and all,

Having searched across the forum this thread has been one of the closest in terms of similarity to my MySQL problem.

Essentially I have some issue with connecting to a MySQL database hosted by our service provider (http://www.123-reg.co.uk/ ). When I contacted them this was their response:

Unfortunately a remote connection it’s not supported with our hosting packages.
However you can try to connect to your database using the steps below:
http://www.123-reg.co.uk/support/answers/Databases/Linux-MYSQL/how-do-i-connect-to-my-mysql-database-4178/

They basically tell me to use PHP to attempt a connection to the server choice.

@Brad Hutchings: I’m attempting to put together the logic to do this and noticed PHP in the IBM link you posted above. Although for different purpose as a beginner how would I go about applying PHP for example in the MySQL sample/example that comes with XOJO?

Just as a mention using the XOJO MySQL example to a Google Cloud MySQL database I created using a gmail account i.e. as seen below:

[code] mDb = New MySQLCommunityServer

mDb.Host = “XXX.XXX.XXX.XXX”
mDb.UserName = “root”
mDb.Password = “xxxxxxxxx”
mDb.DatabaseName = “test”

If mDb.Connect Then
mIsConnected = True
ConnectStatusLabel.Text = “Connected to MySQL”
Else
mIsConnected = False
ConnectStatusLabel.Text = "Error connecting to MySQL: " + mDb.ErrorMessage
End If
[/code]

Cheers for any help.

Alex.