关于JSP的问题!!!!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/11 15:25:09
<%

Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/bbs","root","horizon");
Statement st=con.createStatement();
//String w=session.getAttribute("name");

String strSql="select*from bbsuser where name=?";
ResultSet Rs=st.executeQuery(strSql);
int i;
while(Rs.next()){

String name=Rs.getString("username");
String sex=Rs.getString("sex");
//String content=Rs.getString("bbscontent");
String content=Rs.getString("content");
%>

如果要用?代替参数,需要用PrepareStatement

你想问啥?

select * from bbsuser where name=?;
这句能查询?对mysql不是很熟,不过感觉这儿应该是加参数吧