简体   繁体   English

Java DB 客户端 - 服务器技术 - 集中式 DB - 如何?

[英]Java DB Client-server technology - centralized DB - How?

I have a project this year.今年我有一个项目。 It is about developing a Java application with a database for sharing and validating documents between the manager, secretary and head of finance.它是关于开发一个带有数据库的 Java 应用程序,用于在经理、秘书和财务主管之间共享和验证文档。

My question is: How to make the database accessible by all, since the application will be installed on computers that I mentioned above, do I have to install it (the database) on these computers?我的问题是:如何使所有人都可以访问数据库,因为该应用程序将安装在我上面提到的计算机上,我是否必须在这些计算机上安装它(数据库)? The constraints of consistency and integrity of the database will be violated.将违反数据库的一致性和完整性约束。 The users will not have the same copy after each update!每次更新后,用户将不会拥有相同的副本!

Is there a possibility (or technology in Java) to put the database on the web and there will be accessible by all, or make it accessible from a computer that I realize as a server (client-server).是否有可能(或 Java 中的技术)将数据库放在网络上并且所有人都可以访问,或者可以从我实现为服务器(客户端 - 服务器)的计算机访问它。

I would be grateful for your help or giving links for Tutorials.如果您提供帮助或提供教程链接,我将不胜感激。

在此处输入图片说明

How to make the database accessible by all, since the application will be installed on computers that I mentioned above, do I have to install it (the database) on these computers?如何使数据库所有人都可以访问,因为应用程序将安装在我上面提到的计算机上,我是否必须在这些计算机上安装它(数据库)? The constraints of consistency and integrity of the database will be violated.将违反数据库的一致性和完整性约束。 The users will not have the same copy after each update!每次更新后,用户将不会拥有相同的副本!

Your question suggests that you will need one database on one computer.您的问题表明您将需要在一台计算机上安装一个数据库。 Let's call it a DB computer.我们称它为 DB 计算机。 I'd suggest this be a server, that no one from regular staff, such as secretary, manager, etc... can access.我建议这是一台服务器,普通员工(如秘书、经理等)都无法访问。

Having one central database will eliminate your worries about integrity violation.拥有一个中央数据库将消除您对违反完整性的担忧。

Now, you have two options.现在,您有两个选择。 You can make a web application that your users will use to interact with your system.您可以制作一个 Web 应用程序,您的用户将使用该应用程序与您的系统进行交互。 This is a more modern approach, since you'll have a 3 tier system:这是一种更现代的方法,因为您将拥有一个 3 层系统:

  1. users will access your application via a browser用户将通过浏览器访问您的应用程序
  2. the web application itself is stored on an application server, and it is accessing the database Web 应用程序本身存储在应用程序服务器上,并且正在访问数据库
  3. the database is the backend part数据库是后端部分

The second option is making a desktop application and deploying it to everybody's computer that will use it;第二种选择是制作桌面应用程序并将其部署到每个人的计算机上; and afterwards making it connect to the database for interacting with it.然后使其连接到数据库以与之交互。

The first option is easier when you want to expose your application to a large number of users (and to the web), but know what you're doing when doing stuff like this, since you have to take security very seriously.当您想将应用程序公开给大量用户(和网络)时,第一个选项更容易,但在执行此类操作时要知道自己在做什么,因为您必须非常重视安全性。

If you go the first route, you will need a few things:如果你走第一条路线,你将需要一些东西:

First, a database.首先,一个数据库。 Use what you can, but if you need free and high quality databases, use PostgreSQL or MySQL .尽你所能,但如果你需要免费和高质量的数据库,请使用PostgreSQLMySQL

Second, an application server.二是应用服务器。 I suggest using Tomcat or GlassFish .我建议使用TomcatGlassFish

Now, you need to develop your application using JavaEE .现在,您需要使用JavaEE开发您的应用程序。 There is a wealth of information about this, so I hope this will help you in the beginning and point you in the right direction.有很多关于这方面的信息,所以我希望这能在开始时帮助你并为你指明正确的方向。

Note that Tomcat doesn't support Java EE fully, but a subset of it.请注意,Tomcat 不完全支持 Java EE,而是它的一个子集。 And this subset is surely more than enough for what you need to accomplish.而这个子集肯定足以满足您需要完成的任务。

If I understand you correctly, you are looking for ways to implement a client-server system, where several clients on distinct computers each connect to a central server (or cluster of servers) hosting a DB.如果我理解正确,您正在寻找实现客户端 - 服务器系统的方法,其中不同计算机上的多个客户端分别连接到托管数据库的中央服务器(或服务器集群)。 In Java, usually (but not necessarily) the DB is inside a web application, and the clients are lightweight web clients - in this case it is usually called an enterprise application .在 Java 中,通常(但不一定)数据库位于 Web 应用程序内部,而客户端是轻量级 Web 客户端——在这种情况下,它通常被称为企业应用程序

Java has a whole dedicated SDK for this, called Java Enterprise Edition . Java 有一个完整的专用 SDK,称为Java Enterprise Edition You may find many questions dealing with this on SO , here are a few which I think may be especially helpful:您可能会在 SO 上找到许多与此相关的问题,以下是我认为可能特别有用的一些问题:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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