例子一:
给一个小小的程序,你首先要手动在ODBC中设置eTest,我这个eTest是用access创建的有"FirstName","LastName"的库:
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=GB2312" %>
<%
    String url = "jdbc:odbc:eTest";
    String user = "";
    String password = "";
    Connection con;
    Statement state;
    String query;
    ResultSet result;
    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con = DriverManager.getConnection(url, user, password);
        state = con.createStatement();
        query = "select * from Customers";
        result = state.executeQuery(query);
        boolean bTmp = result.next();
        if (bTmp) out.println(result.getString("FirstName")+"<br/>");
        con.close();
    } catch (Exception e) {
        out.println(e+"<br/>");
    } finally {
        try {
        } catch (Exception e) {}
    }%>  
留言板的页面,和jsp取表单的传入,应该不难。数据库只要设置ODBC和创建好库,就OK啦。例子二、
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="jikeBean" scope="page" class="jike.conn"/>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>留言板</title>
</head><body>            
            <%
             ResultSet RS_result;
             RS_result=jikeBean.executeQuery("select * from mess");
                String UserName;
                String Email;
                String Content;
                while(RS_result.next()){
                  UserName=RS_result.getString("author");
                  Email=RS_result.getString("email");
                  Content=RS_result.getString("content");
                  
            %>
            <TABLE align=center border=1 borderColorDark=#003468 
            borderColorLight=#003468 cellPadding=3 cellSpacing=1 class=b 
            width=500>
              <TBODY>
              <TR bgColor=#e6f2ff class=font1>
                <TD height=16 width=60><font size="2">&nbsp;<font color="#008000">作者</font>&nbsp;</font></TD>
                <TD height=16 width=440><font size="2"><font color="#008000"><%=UserName%></font></TD></TR> 
                            <TR bgColor=#e6f2ff class=font1>
                <TD width=60><font size="2" face="Arial Narrow">&nbsp; <font color="#008000">email</font></font></TD>                          
                <TD height=20 width=440><font size="2"><font color="#008000"><%=Email%></font> 
                </TD></TR> 
                           <TR bgColor=#e6f2ff class=font1>
                <TD height=42 width=60><font size="2" color="#008000">&nbsp;留言</font>
                  <p><font size="2" color="#008000">&nbsp;内容&nbsp;</font></p>
                </TD>
                <TD bgColor=#e6f2ff height=42 vAlign=top width=440><font size="2"><font color="#008000"><%=Content%></font>
                </TD>          
            </table>
            <%
            }
            RS_result.close();
            %>
            <TABLE align=center border=1 borderColorDark=#003468 
            borderColorLight=#003468 cellPadding=3 cellSpacing=1 class=b 
            width=500>
              <TBODY>
              <TR bgColor=#e6f2ff class=font1>
                <TD height=16 width=60><font size="2">&nbsp;<font color="#008000">作者</font>&nbsp;</font></TD>
                <TD height=16 width=440>&nbsp; <INPUT 
                  class=text maxLength=100 name=usertxt size="20" style="color: #00FF00; border-style: solid; border-color: #008000"> 
                </TD></TR> 
                            <TR bgColor=#e6f2ff class=font1>
                <TD width=60><font size="2" face="Arial Narrow">&nbsp; <font color="#008000">email</font></font></TD>                            
                <TD height=20 width=440>&nbsp; <INPUT                            
                  class=text maxLength=100 name=emailtxt size="20" style="border-style: solid; border-color: #008000"> 
                </TD></TR> 
                           <TR bgColor=#e6f2ff class=font1>
                <TD height=42 width=60><font size="2" color="#008000">&nbsp;留言</font>
                  <p><font size="2" color="#008000">&nbsp;内容&nbsp;</font></p>
                </TD>
                <TD bgColor=#e6f2ff height=42 vAlign=top width=440>&nbsp; <TEXTAREA class=text cols=50 name=demo rows=5 style="border-style: solid; border-color: #008000">                  </TEXTAREA>                                 
                </TD>
          
            </table>            <table align=center>
           <INPUT  name=Submit type=submit value=提交 style="font-family: 楷体_GB2312; border-style: solid; border-color: #008000">  
           <INPUT  name=Submit2 type=reset value=重填 style="font-family: 楷体_GB2312; border-style: solid; border-color: #008000">
           </table> 
           <% String sql;%>
<%
if (usertxt!=""&&emailtxt!=""&&demo!="")
 {
  usertxt = request.getParameter("usertxt");
  emailtxt= request.getParameter("emailtxt");
  demo= request.getParameter("demo");
  
  sql = "insert into mess(author,email,content) values('"+usertxt+"','"+emailtxt+"','"+demo+"')";
  jikeBean.executeInsert(sql);
  }else{
  out.print("<b><font color=red>Sorry, Please enter your name,email and message!!!</font></b>");
 }
%>    
           </body>