关于jsp分页浏览中的一个问题
<%Connectioncon;con=LinkDB.getConnection();intintPageSize;intintRowCount;intintPageCo...
<%
Connection con;
con=LinkDB.getConnection();
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;
user user_u;
intPageSize = 10;
strPage = request.getParameter("page");
user_u = ((user)request.getSession().getAttribute("flag")) ;
int id = user_u.getU_id();
if(strPage==null){
intPage =1;
}else{
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql = "select * from teldir where u_id="+id+"and status = 1";
ResultSet rs=stmt.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
代码 原本正常运行 但我把String sql这里(倒数第四行)改成String sql = "select * from teldir where u_id="+id+"and status = 1";后就会出现错误,<%=id %> 验证能正常得到id值 请大神指点问题出在哪里了呢? 展开
Connection con;
con=LinkDB.getConnection();
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;
user user_u;
intPageSize = 10;
strPage = request.getParameter("page");
user_u = ((user)request.getSession().getAttribute("flag")) ;
int id = user_u.getU_id();
if(strPage==null){
intPage =1;
}else{
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql = "select * from teldir where u_id="+id+"and status = 1";
ResultSet rs=stmt.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
代码 原本正常运行 但我把String sql这里(倒数第四行)改成String sql = "select * from teldir where u_id="+id+"and status = 1";后就会出现错误,<%=id %> 验证能正常得到id值 请大神指点问题出在哪里了呢? 展开
1个回答
2014-01-31
展开全部
正常运行的sql是什么,报什么错
追问
String sql = "select * from teldir where u_id=1 and status = 1"; 这样就正常
改成String sql = "select * from teldir where u_id="+id+"and status = 1"; 这样
就报错了。。 id正确显示
追答
"+id+" and 有空格么
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询