我想从data.i中获取数据后更新数据库中的数据。我已经尝试但是它不起作用。请帮助我。谢谢你
<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*,java.sql.*,java.io.*" %>
<%@page import="javax.servlet.*" %>
<%@page import="javax.servlet.http.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>connection with database</title>
</head>
<%
String f_name = request.getParameter("f_name");
out.print(f_name);
String l_name = request.getParameter("l_name");
String gender = request.getParameter("gender");
String cnic = request.getParameter("cnic");
String date = request.getParameter("date");
String inst = request.getParameter("inst");
String dept = request.getParameter("dept");
String deg = request.getParameter("level");
String pro = request.getParameter("pro");
String adm = request.getParameter("admisssion");
%>
<%!Statement s; %>
<%!ResultSet rs; %>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
Statement s=con.createStatement();
s.executeUpdate("update info set first_name='"+f_name+"',last_name='"+l_name+"',gender='"+gender+"',cnic='"+cnic+"',date_of_birth='"+date+"',institute='"+inst+"',department='"+dept+"',degree_level='"+deg+"',programe='"+pro+"',year='"+adm+"')");
}catch(Exception e){ e.printStackTrace(); }
%>
这是代码,但它无法正常工作请帮助我。