日期:2014-05-17  浏览次数:20794 次

jsp操作mysql出现故障
我在做一个信息发布系统,首先要接受注册
从表单获取得数据在填充到数据库时报错
"The server encountered an internal error () that prevented it from fulfilling this request."

代码如下:

   
<%@ page contentType="text/html;charset=gb2312"%> 
  <%@ page import="java.sql.*"%>
//<%@ page language="java" import="java.util.*" session="true">

<html> 
  <body> 
<%
try{
  
  Class.forName("com.mysql.jdbc.Driver").newInstance();
String url=new String("jdbc:mysql://localhost/wrox?user=root&password=xiguagege520&userUnicode=true&characterEncoding=8859_1");
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 

   
  String operate=request.getParameter("operate");
  String username=request.getParameter("username");
  String password=request.getParameter("password");
  String email=request.getParameter("email");
  String sex=request.getParameter("sex");
  String level=request.getParameter("level");
   
   
  String sql="insert into user(username,password,email,sex,level) values('"username+"',MD5('"+password+"'),'"+email+"','"+sex+"','"+level"')";
  ResultSet rs=stmt.executeUpdate(sql); 
  out.println(sql);
  if(rowCount!=0)
  {out.println("command has been done!");}
  else
  {}
   
   
   
   
   
  rs.close(); 
  stmt.close(); 
  conn.close(); 
 }
  catch(Exception e)
  {
  out.print("Exception:"+e.getMessage());
  }

%> 
   
   
  
  </body> 
  </html>

------解决方案--------------------
ResultSet rs=stmt.executeUpdate(sql);
返回错了吧 你编译能成功????
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html