java.sql.SQLSyntaxErrorException: ORA-00904: "PAGENOW1": 标识符无效 5
publicclassWelcomextendsHttpServlet{protectedvoidservice(HttpServletRequestreq,HttpSe...
public class Welcom extends HttpServlet{
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//获取从validation中传入的用户名在位置2
Connection ct=null;
PreparedStatement ps=null;
ResultSet rs=null;
PrintWriter pw=null;
try {
//======================分页功能======================
int pageCount=0;//共有多少页
int pageSize=3;//每页显示多少条记录
int pageNow=1;//希望显示第几页
int rowCount=0;//一共有多少记录
//获取rowCount
Class.forName("oracle.jdbc.driver.OracleDriver");
ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:myoracle","scott","lx0323");
ps=ct.prepareStatement("select count(*)from login");
rs=ps.executeQuery();
if(rs.next()){
rowCount=rs.getInt(1);
}
//计算pageCoutn
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
ps=ct.prepareStatement("select * from (select a1.*,rownum rn from(select * from login)a1 where rownum<=pageSize*pageNow) where rn>=(pageNow-1)*pageSize+1");
rs=ps.executeQuery();
异常如下:
java.sql.SQLSyntaxErrorException: ORA-00904: "PAGENOW1": 标识符无效
提示在rs=ps.executeQuery();这出错
--内容太长了 我截取的出错地方的代码 展开
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//获取从validation中传入的用户名在位置2
Connection ct=null;
PreparedStatement ps=null;
ResultSet rs=null;
PrintWriter pw=null;
try {
//======================分页功能======================
int pageCount=0;//共有多少页
int pageSize=3;//每页显示多少条记录
int pageNow=1;//希望显示第几页
int rowCount=0;//一共有多少记录
//获取rowCount
Class.forName("oracle.jdbc.driver.OracleDriver");
ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:myoracle","scott","lx0323");
ps=ct.prepareStatement("select count(*)from login");
rs=ps.executeQuery();
if(rs.next()){
rowCount=rs.getInt(1);
}
//计算pageCoutn
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
ps=ct.prepareStatement("select * from (select a1.*,rownum rn from(select * from login)a1 where rownum<=pageSize*pageNow) where rn>=(pageNow-1)*pageSize+1");
rs=ps.executeQuery();
异常如下:
java.sql.SQLSyntaxErrorException: ORA-00904: "PAGENOW1": 标识符无效
提示在rs=ps.executeQuery();这出错
--内容太长了 我截取的出错地方的代码 展开
1个回答
展开全部
1、字段名或者表名写错了,仔细检查核对一下,如果实在是没有发现错的地方就有可能是第二种情况了
2、你的字段包含了oracle的关键字,把报错的字段用双引号括起来试试
应该是你这句"select * from (select a1.*,rownum rn from(select * from login)a1 where rownum<=pageSize*pageNow) where rn>=(pageNow-1)*pageSize+1"sql写错了,你在检查下。你用sqldevelper拼写的时候有没有提示什么错误吗?
希望能够帮到你
2、你的字段包含了oracle的关键字,把报错的字段用双引号括起来试试
应该是你这句"select * from (select a1.*,rownum rn from(select * from login)a1 where rownum<=pageSize*pageNow) where rn>=(pageNow-1)*pageSize+1"sql写错了,你在检查下。你用sqldevelper拼写的时候有没有提示什么错误吗?
希望能够帮到你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询