You have not mentioned which MVC framework and which data access mechanism you intend to use. The basic Servlet and JSP spec do not mandate an MVC
pattern - in fact there really isn't an officially recommended MVC framework for Java. Servlets and JSP also say nothing about
JDBC or data access.
There are many ways to write web applications using Java. They range from JSP-based applications where EVERYTHING - including JDBC code to access the database and SQL - can be written in JSPs as inline Java and using various tag libraries (
you should never ever do this, but it is technically possible!) - all the way to enterprise (
JEE) applications with business logic encapsulated in EJB (Enterprise JavaBeans), messaging, routing and transformation fronted by a component based UI framework like JavaServer Faces.
While there is no 'true' Java way to do things, the usual way is to use an MVC framework - such as Spring MVC,
Struts or
JSF for your UI (presentation and basic user interaction). The UI layer delegates to a business logic layer - either POJOs hosted in a container such as the Spring Framework, or EJBs or something similar. The business logic layer would usually use some sort of abstraction for accessing data from a database - something like an ORM (Object-Relational Mapping) framework like Hibernate, or something like Entity EJBs. The data abstraction layer would in turn use data sources defined and configured in the container - either a web container (e.g.
Tomcat etc.) or an application container (eg.
JBoss, WebLogic, WebSphere etc.)
While this may sound like a lot of overhead, it is often the most efficient (in terms of developer productivity). It is often the best way organise things for sclability also.
I often find that the quickest way to get started is to use Spring, Hibernate and Apache Commons DBCP all running as a web application (i.e. a WAR) in Tomcat.
First you define the Spring Application Context in the web.xml (using the Context Listener) pointing it to a Spring XML configuration file.
Then, for the Data Access
1. You instantiate (i.e. define in the XML configuration file) the Hibernate Session Factory (using Spring's implementation of LocalSessionFactoryBean).
2. You define an instance of the Apache Commons BasicDataSource in the Spring context - you can start with username, password, JDBC URL etc. all hardcoded in the Spring XML file, and then move it out later if you wish.
3. You point the Session Factory to the data source.
That is all your basic data access wiring done. Now you can use the Hibernate Session Factory in your business logic beans. Of course, the devil is in the details - you will need to make sure you have packaged your configuration files for both Spring and Hibernate in the right place. You will also have to make sure that you have all the third party library dependencies in your classpath
If you write it well, you should be able to scale this kind of application to any target platform. You could retool your business logic into EJBs to deploy on to an application server platform. You can easily change your data sources to be looked up via JNDI and retrieved from the application container.
You can use the same application context for your MVC - I won't go into the details, but there is plenty of documentation for using Spring MVC available