jsp中向数据库插入信息出错的问题!
代码如下:<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="conn.jsp" %>
<%
String sname=(String)request.getParameter("text1");
String pwd=(String)request.getParameter("text2");
ResultSet rs=stmt.executeQuery("select * from stu");
if(rs.next()){
if(rs.getString("name").equals(sname)){
out.println("用户名已经存在!");
rs.close();
stmt.close();
}
else
PreparedStatement pstmt=conn.prepareStatement("insert into stu(name,password)values(?,?)");
pstmt.setString(1,sname);
pstmt.setString(2,pwd);
pstmt.close();
conn.close();
out.println("注册成功!");
}
%>
问题是: PreparedStatement pstmt=conn.prepareStatement("insert into stu(name,password)values(?,?)");
中PreparedStatement在Eclipse中报错!
请高手帮忙!怎样修改?