简体   繁体   English

具有数据库的良好Java项目架构

[英]Good Java project architecture with database

I facing problem of database connection in my project in which i used struts. 我在使用struts的项目中遇到数据库连接问题。 I cant understand that how i manage my database connections. 我不明白我如何管理数据库连接。 I want my site good in based on accessing becoz it will get million after launch. 我希望我的网站能很好地访问becoz,因此启动后将获得数百万美元的收入。

And also face heap size problem in that . 而且还面临着堆大小的问题。

I cant understand that how i will manage my architechture. 我不明白我将如何管理我的建筑。 Plz guide me,if some one have the knowledge . 如果有人知道,请给我指导。 I want good java architecture with good management of database connection. 我想要良好的Java体系结构和良好的数据库连接管理。

I would suggest you to use Hibernate for DB operation. 我建议您使用Hibernate进行数据库操作。
It is very good ORM tool 这是非常好的ORM工具

There should be 3 modules atleast for your case of architecture. 对于您的体系结构,应该至少有3个模块。

1)WebApp 1)WebApp
2)Service module 2)服务模块
3)Database [Hibernate Module] 3)数据库[​​休眠模块]

Spring has some very good facilities to help you manage DB connections. Spring具有一些非常好的工具来帮助您管理数据库连接。 Have a look at part IV of the documentation : http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/spring-data-tier.html 看一下文档的第四部分: http : //static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/spring-data-tier.html

Spring can help you wether you want to do plain JDBC / SQL or if you want to use a more fancy ORM like Hibernate. Spring可以帮助您进行纯JDBC / SQL或使用像Hibernate这样的更高级的ORM。

If you want to sustain really high load, that's of course just the begining. 如果您要承受很高的负载,那当然只是开始。 You will need a lot of profiling, measuring, tweaking ... 您将需要进行大量的分析,测量,调整...

You can look into the layered architecture approach. 您可以研究分层体系结构方法。 Struts itself is based upon the MVC architectural pattern. Struts本身基于MVC架构模式。

From Wiki , ...In MVC: Wiki ,...在MVC中:

Models are not data access objects; 模型不是数据访问对象。 however, in very simple apps that have little domain logic there is no real distinction to be made. 但是,在域逻辑很少的非常简单的应用程序中,没有真正的区别。

Many applications use a persistent storage mechanism such as a database to store data. 许多应用程序使用诸如数据库之类的持久性存储机制来存储数据。 MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model. MVC没有特别提到数据访问层,因为它被理解为在模型的下方或封装。

So, you can comeup with you own data access layer that would work underneath your Model; 因此,您可以拥有自己的数据访问层,该数据访问层将模型下运行; Checkout A Simple Data Access Layer using Hibernate 使用Hibernate签出简单数据访问层

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

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