4

I'm using delphi at the moment and have a program that connects to another program (a server) which has the mysql database on it and sends the data back to the client. I have a web server that has the server program and the database but my question is can I just go straight from the client program I have made (windows and future mac) to the mysql database on the web server? Or do I really need the server program? If so, what do I need to do to connect my client program to the MySQL database over the internet?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Mike
  • 41
  • 1
  • 2
  • Its possible to have mysql be accessed over the internet directly, but it takes extra effort to try and secure it, and it may not be possible. – becomingwisest Sep 26 '11 at 16:44
  • You said you have 'a web server that has the server program' - what does this 'server program' do right now? Don't reinvent the wheel, especially if you're taking over someone else's code. – Vector Sep 27 '11 at 02:28
  • 2 tier or 3 tier. That's the question. – Sam Sep 27 '11 at 03:16

5 Answers5

1

You should be able to access the mysql database directly as long as you've created a user/pw combo for the database that allows remote access (Security discussion aside). You'll then want to search for a compatible mysql library that would ease the communication between your program and mysql. At the far technical end you might have to read/write directly to the mysql socket but that's possible as well.

Dustin Nielson
  • 1,264
  • 1
  • 8
  • 8
1

Depends on whether your client programs will continue to be native applications or whether you plan to migrate to browser based clients.

If they're native applications you can obtain library components for the languages they're written in which will be able to communicate directly with the MySQL database. There are plenty of options for Delphi; I'm not familiar with what options might be available for native Mac development (but, of course, Embarcadero is in the process of rolling out a Delphi that can generate Mac applications).

If, however, you're planning on making your clients browser-based, ajax solutions want to talk to a web server rather than a database server. In that case, you will need to maintain your middleware. For a discussion of whether it's possible or desirable to have a browser based application communicate directly with a database server see this question.

Community
  • 1
  • 1
Larry Lustig
  • 49,320
  • 14
  • 110
  • 160
1

I would use SOAP/XML for this, and leave the SQL out of the client entirely.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
0

This is a typical use case where REST (for example using JSON encoded database records) can be helpful. It is easy to implement a Delphi client using lkJSON or SuperObject, to put the database records from the HTTP response into a TClientDataSet.

mjn
  • 36,362
  • 28
  • 176
  • 378
0

Yes, it's possible, but is it a good idea?

here's a basic discussion of 2 tier v 3 tier architecture

Sam
  • 2,663
  • 10
  • 41
  • 60