-1

Is there any way to connect DAO files to Servlet.Once Connected we need to get all the database connections in the JSP files used in same project.

I tried this but i cannot connect to DAo.

Dhivya
  • 152
  • 1
  • 2
  • 13
  • 1
    DAO is a design pattern.. It is implemented in many frameworks . Please let us know iny specific framework that you are using. – Pramod S. Nikam May 30 '14 at 12:27
  • @Dhivya: First Keep it in mind, This is not a place to ask code for your need. Please provide your code what you have tried. – ArunRaj May 30 '14 at 12:38

2 Answers2

1

This is wrong architecture. From Servlet (view layer) you should call Service Layer. Service Layer should call DAO Layer and all layers should have access to domain objects (ok view layer should use DTOs..this is controversial).

Any way to your question now. Since you don't specify your framework I give some candidate answers:

  • If you use Spring you can inject DAO with @Autowired
  • If you don't user any framework then you can inject DAO using @Inject
Mike Argyriou
  • 1,250
  • 2
  • 18
  • 30
  • I quite agree with what you said because I did the same way for my basic CRUD project to test MongoDB – Stu_Dent Oct 05 '20 at 12:13
-1

Please refer the following links Which will help you to proceed further.

Data access object (DAO) in Java

http://www.oracle.com/technetwork/java/dataaccessobject-138824.html

Community
  • 1
  • 1
ArunRaj
  • 1,780
  • 2
  • 26
  • 48