How to deal with the website database written in Java, more specifically wicket?

I'm new to web development in Java, but I've started using wicket and created a small web site I want to expand what I have done (a website with forms, tags and links) and realize database connection

I looked at several examples, such as mystic paste, and I saw that they were using hibernate and spring I've never been in contact with hibernate or spring before. To be honest, the heavy use of annotations frightened me because I didn't really use them before, except for suppressing warnings and overriding everything

At this time, I have a connection object, which I set in the webapplication class during initialization Then, whenever I need to execute a query, I retrieve the connection object I don't know if this is a bad way to produce web applications

Thank you very much for all your help

Solution

Wicket, spring and Hibernate are almost standard stacks for wicket applications Or rather, any web framework, spring and Hibernate are almost the standard stack of any web framework

As for wicket, using @ springbean internal components to inject objects is a very good function In addition, opensessioninview filter manages hibernate sessions for you (and Hibernate itself is responsible for connecting)

Therefore, I suggest you study spring and Hibernate - they don't need comments, but they are easier to use most of the time than configuration files (usually XML)

If you still don't want to use spring or hibernate, I suggest you check the opensessioninview filter and create something similar yourself: create a connection for each request, use it during a request, and finally close it Since this will not work well, you may prefer to get a connection from the pool that will return it at the end of the request However, you may have injected the bean into the component instead of writing this code;)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>