我正在使用以下JSP代碼來更新數據庫。它顯示消息「更新成功」,但數據不會在數據庫中更新。使用JSP更新數據庫
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.CallableStatement"%>
<%
String ssiteid=request.getParameter("siteid");
String sowner=request.getParameter("owner");
String sstate=request.getParameter("state");
String sdate=request.getParameter("date");
String stariff=request.getParameter("tariff");
String sdiscom=request.getParameter("discom");
Connection con=null;
try {
Class.forName("com.mysql.jdbc.Driver");
con= DriverManager.getConnection("jdbc:mysql://localhost > /s3n","root","system");
PreparedStatement cstmt= con.prepareStatement("update windtariff_master set Owner=?, State=?, Date=?, Tariff=?, Discom=? where Site_ID=?");
cstmt.setString(1,ssiteid);
cstmt.setString(2,sowner);
cstmt.setString(3,sstate);
cstmt.setString(4,sdate);
cstmt.setString(5,stariff);
cstmt.setString(6,sdiscom);
cstmt.executeUpdate();
out.println("updated successfully");
}
catch(Exception e){
out.print("try not allowed"+e);
}
%>
「//本地主機>/S3N」 你這個 '>' 和/ S3N意思? – Divya
「s3n」是OP連接到的數據庫的名稱。 – duffymo
executeUpdate返回一個int,int的值是什麼? –