在jsp中,用mysql查询报版本错误
这是我报错的代码:
String strId = request.getParameter("id");
if(strId == null || strId.trim().equals("")){
out.println("Error ID");
return;
}
int id = Integer.parseInt(strId);
System.out.println("Id" + id );
Connection conn = DB.getConn();
String sql = "select * from article where rootid = " + strId + "order by pdate asc"; //报错的主题行
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt,sql);
List <Article> articles= new ArrayList <Article>();
while(rs.next()){
Article a = new Article();
a.initfromRs(rs);
articles.add(a);
}
报错的错是: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by pdate asc' at line 1
我再网上查了一下,没有看到一个合适我这问题的答案,有的好像说是什么mysql版本问题。以前也遇到过类似的问题
相关问答:
我是用STRUTS ,做了一个JSP页面,提交后没有存入数据库。
JSP代码如下:
aa.jsp代码
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ taglib uri=" ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
//用客户的session的id建立一个临时文件:
//String tempFileName=(String)session.getId();
String tempFileName = (String)session.getId();
//out.println(& ......
新手:
tomcat+struts 2.0
jsp 页面直接关联model
现在需要根据model(admin)里面的一个item(id),判断jsp页面出现的内容.
大概流程:
...
<table>
<tr>
<td>
<s:if admin.id is null> ......