+++++++++++++++++++++++一个字闷!!!!++++++++++++++++++++++++++++++++++++++++++++++++++++++++
String input2=new String (input.getBytes("ISO-8859-1"));
String subcategory_id=request.getParameter("subcategory_id");
if(input!=null)
{
String sql="select * from news where subcategory_id=? and title like ? ";
PreparedStatement stmt=conn.preparetatement(sql);
stmt.setString(1,subcategory_id);
stmt.setString(2,inupt2);
}
else
{
String sql="select * from news where subcategory_id=?";
PreparedStatement stmt=conn.preparetatement(sql);
stmt.setString(1,subcategory_id);
}
rs=stmt.executeQuery();
========================================================================================
防SQL注入是不是这样写啊???????????????(没有这样改的时候可以链接到数据库读到数据.)
错误:
Generated servlet error:
[javac] Compiling 1 source file
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:253: sql is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
String sql="select * from news where subcategory_id=? and title like ? ";
^
An error occurred at line: 30 in the jsp file: /other/operation.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:254: cannot resolve symbol
symbol : method preparetatement (java.lang.String)
location: class jmeport.conn
PreparedStatement stmt=conn.preparetatement(sql);
^
An error occurred at line: 30 in the jsp file: /other/operation.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:256: cannot resolve symbol
symbol : variable inupt2
location: class org.apache.jsp.other.operation_jsp
stmt.setString(2,inupt2);
^
An error occurred at line: 30 in the jsp file: /other/operation.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:261: sql is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
String sql="select * from news where subcategory_id=?";
^
An error occurred at line: 30 in the jsp file: /other/operation.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:262: cannot resolve symbol
symbol : method preparetatement (java.lang.String)
location: class jmeport.conn
PreparedStatement stmt=conn.preparetatement(sql);
^
An error occurred at line: 30 in the jsp file: /other/operation.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\other\operation_jsp.java:267: cannot resolve symbol
symbol : variable stmt
location: class org.apache.jsp.other.operation_jsp
rs=stmt.executeQuery();
^