The method preparedStatement(String) is undefined for the type Connection
org.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:11...
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 11 in the jsp file: /masql.jsp
The method preparedStatement(String) is undefined for the type Connection
8: Connection conn= DriverManager.getConnection(url,us,pw);
9: DatabaseMetaData metadata=conn.getMetaData();
10: ResultSet rs1=metadata.getColumns(null,null,"user",null);
11: PreparedStatement pre=conn.preparedStatement("select * from user");
12: rs=pre.executeQuery();
13: out.print("<table>");
14: while(rs.nest()){
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
String pw = "gyp";
String us = "root";
String url ="jdbc:mysql://localhost/lts";
Connection conn= DriverManager.getConnection(url,us,pw);
DatabaseMetaData metadata=conn.getMetaData();
ResultSet rs1=metadata.getColumns(null,null,"user",null);
PreparedStatement pre=conn.preparedStatement("select * from user");
rs=pre.executeQuery();
out.print("<table>");
while(rs.nest()){
out.print("<tr><td>"+new String(rs.getString(1).getBytes("gb2312"),"iso-8859-1")+"</td>");
out.print("<td>"+new String(rs.getString(2).getBytes("gb2312"),"iso-8859-1")+"</td></tr>");
}
out.print("</table>");
}catch(Exception e)
{}
%>
我想知道错误产生的原因和解决方法 展开
An error occurred at line: 11 in the jsp file: /masql.jsp
The method preparedStatement(String) is undefined for the type Connection
8: Connection conn= DriverManager.getConnection(url,us,pw);
9: DatabaseMetaData metadata=conn.getMetaData();
10: ResultSet rs1=metadata.getColumns(null,null,"user",null);
11: PreparedStatement pre=conn.preparedStatement("select * from user");
12: rs=pre.executeQuery();
13: out.print("<table>");
14: while(rs.nest()){
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
String pw = "gyp";
String us = "root";
String url ="jdbc:mysql://localhost/lts";
Connection conn= DriverManager.getConnection(url,us,pw);
DatabaseMetaData metadata=conn.getMetaData();
ResultSet rs1=metadata.getColumns(null,null,"user",null);
PreparedStatement pre=conn.preparedStatement("select * from user");
rs=pre.executeQuery();
out.print("<table>");
while(rs.nest()){
out.print("<tr><td>"+new String(rs.getString(1).getBytes("gb2312"),"iso-8859-1")+"</td>");
out.print("<td>"+new String(rs.getString(2).getBytes("gb2312"),"iso-8859-1")+"</td></tr>");
}
out.print("</table>");
}catch(Exception e)
{}
%>
我想知道错误产生的原因和解决方法 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询