 <%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<HTML>
<BODY  >
<Font size=4>
<P>添加新的记录到数据库：
<FORM action="xiti4_insert.jsp" method=post>
	书号：
	<Input type="text" name="shuhao">
	<BR>书名：
	<Input type="text" name="shuming">
	<BR>出版社：
	<Input type="text" name="chubanshe">
	<BR>作者：
	<Input type="text" name="zuozhe">
	<BR>出版日期：
	<Input type="text" name="riqi">
	<BR><Input type="submit" name="b" value="提交添加">
</FORM>

<P>数据库添加记录前的数据记录是：
 <% String shuhao,shuming,chubanshe,zuozhe,riqi;
    Connection con;
    Statement sql; 
    ResultSet rs;
    try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       }
    catch(ClassNotFoundException e){}
    try { 
		con=DriverManager.getConnection("jdbc:odbc:aaa","sa","");
         	sql=con.createStatement();
         	rs=sql.executeQuery("SELECT * FROM books");
         	out.print("<Table Border>");
         	out.print("<TR>"); 
            	out.print("<TH width=100>"+"书号");
            	out.print("<TH width=100>"+"书名");
            	out.print("<TH width=100>"+"出版社");
            	out.print("<TH width=100>"+"作者");
            	out.print("<TH width=100>"+"出版日期");
            	out.print("</TR>");
       		while(rs.next())
       		{ 
			out.print("<TR>");
             		shuhao=rs.getString(1); 
             		out.print("<TD >"+shuhao+"</TD>"); 
             		shuming=rs.getString(2); 
             		out.print("<TD >"+shuming+"</TD>");
             		chubanshe=rs.getString(3); 
             		out.print("<TD >"+chubanshe+"</TD>"); 
             		zuozhe=rs.getString(4); 
             		out.print("<TD >"+zuozhe+"</TD>");
             		riqi=rs.getString(5); 
             		out.print("<TD >"+riqi+"</TD>");   
        		out.print("</TR>") ; 
        	}
        	out.print("</Table>");
        	con.close();
     	}
     catch(SQLException e1) {}
 %>
</Font>
</BODY>
</HTML>

 
 
 
 
 
 
 
 
 
 
 
 