neuresult.jsp
<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.sql.*" import ="java.util.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<html>
<body bgcolor=cyan>
<%
String name=request.Parameter("name");
if(name==null)
{
name="";
}
byte b[]=name.getBytes("ISO-8859-1");
name=new String(b);
String chubanshe=request.Parameter("chubanshe");
if(chubanshe==null)
{
chubanshe="";
}
byte c[]=chubanshe.getBytes("ISO-8859-1");
chubanshe=new String(c);
String zuozhe=request.Parameter("zuozhe");
if(zuozhe==null)
{
zuozhe="";
}
byte d[]=zuozhe.getBytes("ISO-8859-1");
zuozhe=new String(d);
String leibie=request.Parameter("leibie");
if(leibie==null)
{
leibie="";
}
byte e[]=leibie.getBytes("ISO-8859-1");
leibie=new String(e);
String bianhao=request.Parameter("bianhao");
if(bianhao==null)
{
bianhao="";
}
byte f[]=bianhao.getBytes("ISO-8859-1");
bianhao=new String(f);
Connection con=null;
Statement sql=null;
ResultSet rs=null;
String nbianhao,nname,nchubanshe,nleibie,nzuozhe;
String str="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\datafile\\tushu1.mdb";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException event){}
try
{
con=DriverManager.getConnection(str,"","");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String condition="INSERT INTO tushu2 values "+"("+"'"+bianhao+"','"+name+"','"+zuozhe+"','"+chubanshe+"','"+leibie+"')";
sql.executeUpdate(condition);
%>
<p>添加后的记录:
<%
rs=sql.executeQuery("select * from tushu2");
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>");
nbianhao=rs.getString("编号");
out.print("<TD>"+nbianhao+"</TD>");
nname=rs.getString("图书名");
out.print("<TD>"+nname+"</TD>");
nzuozhe=rs.getString("作者");
out.print("<TD>"+nzuozhe+"</TD>");
nchubanshe=rs.getString("出版社名");
out.print("<TD>"+nchubanshe+"</TD>");
nleibie=rs.getString("类别");
out.print("<TD>"+nleibie+"</TD>");
out.print("</TR>");
}
out.print("</Table>");
rs.close();
sql.close();
con.close();
}
catch(SQLException event){}
%>
</body>
</html>