Hi Guys,

I am new to Java and looking into best way of doing J2ee database conectivity. I am using Eclipse galileo3.5 J2EE with Mysql database and Tomcate 6.0.

I am developing an email application where I need to implement MVC model for my webapplication, using jsp for presentation, servlet for control and java beans for model.

I came across two tutorial for database connection pooling as given below.

[url=http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html] Eclipse Corner Article: Creating Database Web Applications with Eclipse - In this tutorial connection pooling is configure in Tomcate 6.0

It says Copy and paste the following into your context.xml file (you may have to click on the Source tab at the bottom of the editor to be able to paste). This defines a DataSource with the name "jdbc/SampleDB". Our application will retrieve database connections from the pool using this name.

<?xml version="1.0" encoding="UTF-8"?>

<Resource name="jdbc/SampleDB" auth="Container"
username="app" password="app"
driverClassName="org.apache.derby.jdbc.ClientDrive r"
maxActive="8" />

Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
It uses java bean for connection pooling and then use straight way in JSP and no Servlet used.

<%@page import="java.sql.Connection"%>
<jsp:useBean id="pl" class="com.CoreJava.ConnectionPooling"/>
<% Connection con = pl.getConnection(); %>
//do something using con


import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolD ataSource;

public class ConnectionPooling
static Connection con=null;
public static Connection getConnection()
MysqlConnectionPoolDataSource po=new MysqlConnectionPoolDataSource();
po.setDatabaseName("mydatabase"); //changeur database name
po.setUser("root");//ur username
po.setPassword("");//ur password
con = po.getConnection();
catch(Exception e)
System.out.println("Exception Connection :"+e);
return con;

Please some one explain which is the best way of doing connection pooling to the database by using MVC pattern

Please if some one advise me how to use MVC architecture for simple email application and database connectivty.