评论信息
<%
Connection comcon;
Statement comsql;
ResultSet comrs;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
out.print("驱动异常");
}
comcon = DriverManager.getConnection("jdbc:mysql://localhost/db_bbs", "root", "");
comsql = comcon.createStatement();
String comment = null;
comment = "select comment,time from comment where subid = (select id from send where id ='" + id + "')";
comrs = comsql.executeQuery(comment);
try {
while (comrs.next()) {
%>
<%=comrs.getString("comment")%>
<%=comrs.getDate("time")%> <%=comrs.getTime("time")%>
<%
}
} catch (Exception e) {
out.print("无法显示评论信息");
}
comsql.close();
comrs.close();
comcon.close();
String k1 = request.getQueryString();//得到ID的值(id=数字).
String re = "\\D+";
String result = k1.replaceAll(re, ""); //找到不是数字的字符,用""替代
%>