
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<HTML>
<BODY>
<FONT size=4>
<P>添加新的记录到数据库：
<FORM action="insertUpdata.jsp" method=post>
同学学号：
<INPUT type="text" name="number">
<BR>同学姓名：
<INPUT type="text" name="name">
<BR>操作系统成绩：
<INPUT type="text" name="math">
<BR>微机原理成绩：
<INPUT type="text" name="english">
<BR>数据结构成绩：
<INPUT type="text" name="physics">
<BR><INPUT type="submit" name="b" value="提交添加">
</FORM>
<P>数据库添加记录前的数据记录是：
<% 
	String name,number;
    	int math,physics,english;
    	Connection con;
    	Statement sql; 
    	ResultSet rs;
    	try{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       	   }
    	catch(ClassNotFoundException e){}
    	try { 
		con=DriverManager.getConnection("jdbc:odbc:sun","sa","");
         	sql=con.createStatement();
         	rs=sql.executeQuery("SELECT * FROM student");
         	out.print("<TABLE Border>");
         	out.print("<TR>");
            	out.print("<TH width=100>"+"学号");
            	out.print("<TH width=100>"+"姓名");
            	out.print("<TH width=50>"+"操作系统");
            	out.print("<TH width=50>"+"微机原理");
            	out.print("<TH width=50>"+"数据结构");
         	out.print("</TR>");
       		while(rs.next())
       		{ 
			out.print("<TR>");
             		number=rs.getString(1); 
             		out.print("<TD >"+number+"</TD>"); 
             		name=rs.getString(2); 
             		out.print("<TD >"+name+"</TD>");
             		math=rs.getInt(3); 
             		out.print("<TD >"+math+"</TD>"); 
             		english=rs.getInt(4); 
             		out.print("<TD >"+english+"</TD>");
             		physics=rs.getInt(5); 
             		out.print("<TD >"+physics+"</TD>");   
        		out.print("</TR>") ; 
        	}
        	out.print("</TABLE>");
        	con.close();
     	}
   	catch(SQLException e1) {}
%>
</FONT>
</BODY>
</HTML>
