<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试修改删除添加数据对ACCESS</title>
</head>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){
out.print("数据库驱动程序装入错误");
}
try{
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+request.getRealPath("/")+"db.mdb";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
//stmt.executeUpdate("insert into admin(name,pass) values('kaikai','kaikai')"); //添加
//stmt.executeUpdate("delete from admin where nID=2"); //删除
stmt.executeUpdate("update admin set pass=111 where nID=1"); //修改
stmt.close();
conn.close();
}
catch(Exception ex){
out.print(ex);
}
%>
<body>
</body>
</html>