简体   繁体   中英

What is the best way to use Web database using Delphi?

all. I'm using DBExpress and C++ Builder(Delphi) 2007 and MySQL, firebird , ... I'd like to make win 32 application which use Database(located on my web server). I tried using DBExpress (TSQLConnection for MySQL), it's so so slow... and I tried local database then upload/download using Indy.. but it was not good and little complicated. So what is the base way to use web-based database for win 32 application? Do you have any experience? or any document or any comment will be so so graceful.. thanks a lot..

Database connections via an Internet link (using a VPN or not) are slow - you are perfectly right. The main reason IMHO is the "ping" delay of every request, which is very low on a local network, and much higher via Internet. So direct connection is not a good idea.

In latest versions of Delphi, you have the DataSnap components, which is the new "standard" (or Embarcadero recommended) way of doing remote access (including web access). Even if it was found at first to be a bit limited , the latest versions are perfectly usable, and are becoming a key product for cross-platform application building with Delphi. But it is not available for Delphi 2007.

One much matured product (and available for Delphi 2007) is Data Abstract :

Data Abstract is a framework for building database-driven applications using the multi-tier data access model, for a variety of platforms.

Of course, this is not free, but this is a proven and efficient solution.

You may also take a look at our Client-Server ORM , which can connect to any DB , and is able to implement a RESTful SOA architecture with Delphi 2007 , even without using the ORM part - that is, you can use your existing DBExpress-based source code, and expose easily some web interfaces to the data. It is Open Source, and uses JSON as communication format over a secured authentication mechanism . There is a lot of documentation included (more than 700 pages of PDF), which also tries to introduce to the SOA world .

看看Datasnap: 信息

You need a data access library, which offers features:

  1. Thread safety. In general, you will need to use a dedicated connection for each thread.
  2. Connection pooling. To make connection creation (what is needed for (1)) fast, there must be a connection pool.
  3. Fast execute SQL command, open result set, fetch capabilities.
  4. Tracing. With any one library you may run into performance issues. You need a tool to see what is going on wrong. For that you will need to see and analyze the client and server communication.
  5. Result set caching and ability to read it simultaneously from different threads. You may have few read-only tables, which you will fetch once and cache in your application. But you will need a machanism to read this data from threads. Kind of InMemTable cloning.

My answer is biased, but you may consider AnyDAC . It has all these and many other features.

PS: dbExpress should work too. Try to find first the reason for your performance issue, and not a different library. Because the same may happen with other library ...

DB applications over a slow link need a different approach than those using a fast link. You have to be careful about how much data you move around, and about how many roundtrips your application perform.

Usually an approach when the needed subset is cached on the client, modified, and the applied to the database is preferrable (of course if changes do not neeed to be seen immediately, and the chances of conflicts are low).

No middleware will help you much if the application is not designed with handling a slow link in mind.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM