我是 java servlet 的初学者,我的问题是我想生成一个帐号。每次我的桌子上都会有一个新帐户。但是触发器不工作请帮助 fname lname 用户名和 pword 等其他值工作正常 servlet 没问题,但创建 accno 的触发器工作不正常
CREATE OR REPLACE TRIGGER T1 BEFORE INSERT ON UINFO
FOR EACH ROW
BEGIN
set new.UACCNO="jith"||to_char(SQ_1.nextval,'FM0009');
END;
/
//this is my servlet prog
String s1=hreq.getParameter("fname");
String s2=hreq.getParameter("lname");
String s3=hreq.getParameter("uacc");
String s4=hreq.getParameter("uname");
String s5=hreq.getParameter("pword");
String s6=hreq.getParameter("pword2");
String s7[]=hreq.getParameterValues("select");
String s8=hreq.getParameter("uans");
String s9=hreq.getParameter("ueid");
PrintWriter pw=hres.getWriter();
//if passwords match
if(s6.equals(s5))
{
PreparedStatement pstmt=con.prepareStatement("insert into uinfo(fname,lname,uacc,uname,pword,uques,uans,ueid) values(?,?,?,?,?,?,?,?)");
pstmt.setString(1,s1);
pstmt.setString(2,s2);
pstmt.setString(3,s3);
pstmt.setString(4,s4);
pstmt.setString(5,s5);
for(int i=0;i<s7.length;i++)
{
if(s7[i]!=null)
pstmt.setString(6,s7[i]);
}
pstmt.setString(7,s8);
pstmt.setString(8,s9);
pstmt.executeUpdate();
pw.println("<html><body bgcolor=wheat text=blue>");
pw.println("<h1>user "+s4+" has Registered successfully</h1><br/><br/>");
pw.println("<h3><a href=login.html>Login Now?</a></h3>");
pw.println("</body></html>");
}
else
{
pw.println("<html><body bgcolor=wheat text=blue>");
pw.println("<h1>**the passwords do not match go back and check</h1>");
pw.println("</body></html>");
}