jsp mysql的代码提示错误_JSP里面关于读取MYSQL的数据的时候出错

ConnectionPool cpool=(ConnectionPool)application.getAttribute("ConnectionPool");

while(cpool==null)

{

%>

cpool=(ConnectionPool)application.getAttribute("ConnectionPool");

}

Connection con=cpool.getConnection();

Statement stm=con.createStatement();

String sQuery="SELECT NEWS_ID,NEWS_DATE,NEWS_TITLE FROM NEWS ORDER BY NEWS_DATE DESC LIMIT 0,15";

ResultSet rlt=stm.executeQuery(sQuery);

sQuery="select ID from pics_image order by ID asc LIMIT 1, 1";

ResultSet rpt=stm.executeQuery(sQuery);

while(rpt.next())

{

//String Pic_Count=rpt.getString("ID");

pp=rpt.getString("ID");

out.print(pp);

}

out.print(pp);

rpt.close();

cpool.returnConnection(con);

cpool=null;

con=null;

%>

代码是这样的 如果把out.print放在while里面网页可以显示 但是如果放到外面就会报错。。如果其他地方调用PP这个变量一样会报错。。我主要是想调用这个变量。。请问有什么方法可以不出错?

错误代码是

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented

it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 29 in the jsp file: /MYSQLTEST.jsp

The local variable pp may not have been initialized

26: pp=rpt.getString("ID");

27:

28: }

29: out.print(pp);

30: rpt.close();

31: cpool.returnConnection(con);

32: cpool=null;

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值