只用JSP的话。只要把mysql-connector-java-3.0.8-stable-bin.jar扔到Tomcat的lib下,如果是Resin的话也是扔到lib目录下就行了。classpath也不用设了。
下面是我的一个例子
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://10.1.10.35:3306/test";
//String user="root";
//String password="123";
Connection conn= DriverManager.getConnection(url);//(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from jsp";
ResultSet rs=stmt.executeQuery(sql);
out.println("<BR> <table><tr>");
out.println("<td>Name</td>");
out.println("<td>age</td>");
out.println("<td>city</td>");
out.println("<td>state</td>");
out.println("<td>country</td>");
out.println("<td>postcode</td>");
out.println("<td>email</td>");
out.println("</tr>");
while(rs.next()) {%>
<tr>
<td><%=rs.getString(1)%> </td>
<td><%=rs.getString(2)%> </td>
<td><%=rs.getString(3)%> </td>
<td><%=rs.getString(4)%> </td>
<td><%=rs.getString(5)%> </td>
<td><%=rs.getString(6)%> </td>
<td><%=rs.getString(7)%> </td>
</tr>
<%}
out.println("</table>");
%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
123123
</body>
</html>
</body>
</html>