jsp连接oracle老是报错 写了一个jsp连接数据库的程序,代码如下,老是报错,求改正
<%@page import="java.sql.*"%>
<%!
public static final String DBDRIVER="oracle.jdbc.driver.OracleDriver";//驱动
public static final String DBURL="jdbc:oracle:thin:@localhost:1521:orcl";
public static final String DBUSER="scott";
public static final String DBPASS="tiger";
%>
<%
String userid = request.getParameter("userid");
String password = request.getParameter("password");
boolean flag=false;
%>
<%
try{
Connection conn=null;
PreparedStatement ppstm=null;
ResultSet rs=null;
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,DBUSER,DBPASS);
String sql ="select userid,name from tuser where userid=? and password=?";
ppstm =conn.preparedStatement(sql);
ppstm.setString(1,userid);
ppstm.setString(2,password);
rs=ppstm.executeQuery();
if(rs.next()){
flag=true;
}
}catch(Exception e){
}finally{
try{
conn.close();
}catch(Exception e){}
}
if(flag){
%>
<jsp:forward page="right.jsp"/>
<%
}else{
%>
<jsp:forward page="wrong.jsp"/>
<%
}
%>
错误如下 org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 21 in the jsp file: /check.jsp
The method preparedStatement(String) is undefined for the type Connection
18: Class.forName(DBDRIVER);
19: conn=DriverManager.getConnection(DBURL,DBUSER,DBPASS);
20: String sql ="select userid,name from tuser where userid=? and password=?";
21: ppstm =conn.preparedStatement(sql);
22: ppstm.setString(1,userid);
23: ppstm.setString(2,password);
24: rs=ppstm.executeQuery();
An error occurred at line: 31 in the jsp file: /check.jsp
conn cannot be resolved
28: }catch(Exception e){
29: }finally{
30: try{
31: conn.close();
32: }catch(Exception e){}
33: }
34: if(flag){