jsp中往access数据库添加数据

2024-12-16 00:37:33
推荐回答(1个)
回答1:


<%
if(request.getParameter("submiting")!=null)
{
//String id = request.getParameter("id");
String tigan = request.getParameter("tigan");
String daan = request.getParameter("daan");
String zhang = request.getParameter("zhang");
String a = request.getParameter("a");
String b = request.getParameter("b");
String c = request.getParameter("c");
String d = request.getParameter("d");
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:member";
String username="";
String password="";
Connection con=DriverManager.getConnection(url,username,password);
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into xuanzeti values('"+tigan+"','"+daan+"','"+zhang+"','"+a+"','"+b+"','"+c+"','"+d+"')");

stmt.close();

con.close();
写到tianjiatimu.jsp里