DAO + Webservice

Asked

Viewed 318 times

1

I want to use the DAO standard to create a Java project in Eclipse to view data from a database. Only I want to turn it into a Webservice.. How should I proceed? Just use that IDE Webservice creation option and you’re done?

  • 2

    You can use the DAO pattern quietly in a WebService. In my case I use Vraptor, I do the project normally and just call the method that is on the DAO in my controller.

2 answers

1


Well, apparently your question is about the structure of the project, right? In the IDE vc creates a dynamic web project (Dynamic Web project), it also supports you in choosing the libraries you will need in your project. As for Pattern DAO, it’s a class design you’ll use to manipulate the database. I advise you to structure your project using MVC with DAO.

  • Then, I can write the methods (Establish database connection and list data) in one class and then generate the Webservice?

  • Of course, as the brother remarked above, you should think about separating layers. the DAO will only serve to make transactions (CRUD) in the database. these transactions will be managed by a controller (methods that call the DAO methods) and send the result to your preview layer (webservice). , just a doubt, vc is using which language and which persistence technology?

  • Using : Java, postgres and JDBC. I just want something simple that involves RMI, that is : I have to establish connection to the database and list database data. I don’t want to use frameworks, like Hibernate, because I have to finish a job soon, I’m running out of time and I’m kind of lost.

  • Sorry for all these boring questions... I’m a beginner in Web services.

  • All right, no fuss.

  • well, in this case your doubt is the question the connection with the bank?

  • Yes... Because I want the client to consume the web service to have no problems when establishing the connection.

  • Well, you’ll have to take a look at the connection pool and datasource. For this you must configure your Application Server or if this is the case of the web container, I use the glassfish app server. This will cause the application server to manage the connections with the application, in which case several clients may be connected simultaneously to your application. Well, if that’s what I understand from your question. : ) which doesn’t have much to do with DAO.

Show 3 more comments

0

You should think about separating layers before anything else.

Let’s think, the DAO Pattern is a standard for access to the database, it is a layer for this, should not imagine it with another responsibility beyond this, this is a concept of SRP.

Separating in layers, we must have at least one more to implement the layer of web services or endpoint, we must have this layer to expose its functionalities or data.

That is, DAO + Rest, DAO + SOAP, DAO + RTC, etc.

And a hint, make this layer, don’t let IDE or other tools do it for you, try to understand what you’re writing and are trying to implement.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.