search

Home  >  Q&A  >  body text

jsp, servlet, dao implement MVC architecture where generally everyone closes the database connection

No need for various frameworks, just a model like JSP+Servlet+Dao

There are two main problems
1. In theory, Dao is responsible for the database, so all operations with the database (including closing connection, statement, resultsset) should be completed within dao. However, sometimes a certain operation in a servlet involves calling multiple daos, which means that the corresponding connection may be opened and closed multiple times, seriously affecting performance. So should we move it to a servlet?

2. When closing, if the connection is closed, the statement and resultsset will be closed automatically, so you don’t have to work hard to close them all.

为情所困为情所困2740 days ago567

reply all(1)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:08:07

    1 Database connection pool
    2 No, statement and resultsset need to be released manually

    reply
    0
  • Cancelreply