myeclipse下的web應用
有一個登錄注冊功能,登陸的時候讀取數據庫可以,
但是注冊要寫入進去就不行
register.jsp
<%@ page language="java" import="java.util.*,java.sql.*,cn.edu.dhu.*"%>
<%@ page contentType="text/html,charset=utf-8" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<%
String name = request.getParameter("usernamesignup");
String account = request.getParameter("emailsignup");
String pswd1 = request.getParameter("passwordsignup");
String pswd2 = request.getParameter("passwordsignup_confirm");
System.out.println("name="+name);
System.out.println("name="+account);
System.out.println("name="+pswd1);
System.out.println("name="+pswd2);
if(account !=null && pswd2!=null){
System.out.println("執行到了");
String sql = "use jsgl;insert into jsgl.user values('"+name+"','"+account+"','"+pswd1+"','"+pswd2+"')";
System.out.println("執行到了");
Connection conn=DB.getConn();
System.out.println("執行到了");
Statement stmt = DB.createStmt(conn);
System.out.println("執行到了");
int n = DB.executeUpdate(stmt, sql);
response.sendRedirect("index.jsp");
System.out.println("執行到了");
}
%>
<body>
</body>
</html>
都執行到了,但是數據庫裡面沒有信息
ps:從命令行敲insert語句是可以插入的 myeclipse這裡不行的
求幫忙
insert into jsgl.user values('"+name+"','"+account+"','"+pswd1+"','"+pswd2+"')";
是不是應該改為insert into user values('"+name+"','"+account+"','"+pswd1+"','"+pswd2+"')";