日期:2014-05-18  浏览次数:20606 次

有关一个注册问题
环境JDK+TOMCAT
jsp代码:
  <%@   page   contentType= "text/html;charset=GB2312 "   %>
<%@   page   import= "java.sql.* "   %>
<html>
<head>
<%
response.setCharacterEncoding( "GBK ");
String   name=request.getParameter( "name ");
String   pass=request.getParameter( "password ");
String   telephone=request.getParameter( "telephone ");
String   adress=request.getParameter( "adress ");
String   birthday=request.getParameter( "birthday ");
try
{
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
}
catch(ClassNotFoundException   e)
{
out.print( "类找不到! ");
}
String   url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=myjob ";
String   user= "sa ";
String   password= " ";
Connection   conn=   DriverManager.getConnection(url,user,password);
Statement   stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String     s= " ' "+name+ " ' "+ " ' "+ " ' "+pass+ " ' "+ " ' "+ " ' "+telephone+ " ' "+ " ' "+ " ' "+adress+ " ' "+ " ' "+ " ' "+birthday+ " ' ";
String     verify= "insert   into   user1     values   "+ "( "+s+ ") ";
ResultSet   rs=stmt.executeQuery(verify);
if(rs.next()){        
response.sendRedirect( "index.jsp ");}
else{      
response.sendRedirect( "zhuce.jsp ");}    
rs.close();          
stmt.close();          
conn.close();  
%>
</head>

<body>
</body>
</html>
当我运行页面的时候提示:
org.apache.jasper.JasperException:   javax.servlet.ServletException:   java.sql.SQLException:   [Microsoft][SQLServer   JDBC   Driver][SQLServer]在关键字   'null '   附近有语法错误。
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root   cause  

javax.servlet.ServletException:   java.sql.SQLException:   [Microsoft][SQLServer   JDBC   Driver][SQLServer]在关键字   'null '   附近有语法错误。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org