简体   繁体   中英

JDBC driver in WebApp or Tomcat

I am using Postgres and JDBC to query DB. I am also using Spring and Tomcat container.

I would like to use pure JDBC because of performance gains, which is priority in my project.

I would like to avoid copying Postgres SQL driver lib (in my case: postgresql-9.1-901.jdbc3.jar ) to Tomcat's library folder. I am using the one within webapp - in /WEB-INF/lib/

  • Some people say that this is bad practice - why?

The reason is quite simple, you cannot update the driver without rebuilding the whole application. This is not a big issue, if you are controlling the source code, and can redeploy quickly. But if you are a customer, paying for an application (without source and build environment), you would not prefer this solution.

Also, if there are multiple applications on the application server with the same dependency, then you are loading the same jar (or worse: different versions of the same jar) multiple times, which is wasteful.

At the end of the day, throwing it in /WEB-INF/lib is better for the developer, while putting it into the /lib is better for the software administrators.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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