将桌面客户端直接连接到MySQL是明智的吗? [英] Is it sensible to connect a desktop client directly to MySQL?

查看:177
本文介绍了将桌面客户端直接连接到MySQL是明智的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个从远程MySQL服务器检索数据的Java桌面客户端应用程序。为了开发目的,我已经直接连接到MySQL服务器(即使用DriverManager.getConnection(databaseURL)等),但一直打算转向使用Web服务(一旦已经建立)。我的问题是,我不能只是继续直接连接?

I'm writing a Java desktop client application that retrieves data from a remote MySQL server. For development purposes I have had it connecting directly to the MySQL server (i.e. with DriverManager.getConnection(databaseURL) etc.), but have been intending to move to using a web service (once that'd been built). My question is whether I couldn't just continue with the direct connection?

什么是Web服务给我以外的更多的代码写?我必须实现我自己的身份验证;我只是依靠MySQL的?有什么问题?

What is the web service going to give me other than more code to write? I would have to implement my own authentication; what's wrong with just relying on MySQL's?

(我把这个问题写成是否定的,因为我认为这个范例在这些日子里有点皱眉。这真的是为什么我问它,因为它在我看来是一个完全不错的事情。)

(I'm phrasing this question rather in the negative, because I get the idea that this paradigm is somewhat frowned upon these days; that's really why I'm asking it, because it seems to me to be a perfectly okay thing to do.)

感谢您能够提供任何洞察力我!

Thank you for any insight you may be able to give me!

推荐答案

很好,只要给客户端一个只有正确权限的用户,任何错误,直接连接到MySQL。也许如果你将有很多很多这些客户端运行,这将保持与MySQL的许多连接打开,而Web服务可以使用单个连接并处理来自所有客户端的负载。

Well, so long as you give the client a user with only just the right permissions, I don't see anything wrong with connecting directly to MySQL. Maybe if you're going to have lots and lots of these clients running, which will keep a lot of connections to MySQL open, while a web service could use a single connection and handle the load from all clients.

Web服务的真正用途是当你有很多业务逻辑不能在数据库中。将这个逻辑放在客户端是一个非常糟糕的主意,因为用户可能运行过时的版本,等等。此外,Web服务允许您拥有不同类型的客户端(例如Windows客户端,Web客户端等),而无需重写任何逻辑,除了表示。

The true usefulness of a web service is when you have a lot of business logic that can't be in the database. Putting this logic in the client is a very bad idea because users may run outdated versions, and so on. Also, a web service allows you to have different types of clients (such as a Windows client, a web client, etc.) without having to rewrite any logic besides presentation.

这篇关于将桌面客户端直接连接到MySQL是明智的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆