<%
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String createTime=sdf.format(date);
ResultSet rsALL=null;
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/mssql");
Connection conn=ds.getConnection();
PreparedStatement strSQL=conn.prepareStatement("select * from Production");
rsALL=strSQL.executeQuery();
%>
<table>
<tr>
<td>物品号</td>
<td>物品类型</td>
<td>物品名</td>
<td>物品价格</td>
<td>物品数量</td>
<td>发布时间</td>
<td>图片</td>
</tr>
<%
int pagesize= 3;//一页几条
rsALL.last();
int rowCount = rsALL.getRow();
int maxPage = 0;
maxPage = (rowCount%pagesize==0)?(rowCount/pagesize):(rowCount/pagesize+1);
int curPage = 1;
if(curPage <1)curPage = 1;
if(curPage > maxPage ) curPage = maxPage;
rsALL.absolute((curPage-1)*pagesize+1);
for(int i=1;i<=pagesize;i++)
{
%>
我通过浏览器就提示rsALL.las() (上文代码25行)有问题,百度后提示是可能是空指针的问题。我这个是从另一个注册页面改过来的,也不知道哪里有问题,刚学不久。希望大神可以讲明白些,哪里出问题了。
------解决思路----------------------
你的connection没有建立起来
导致返回不了结果集
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/mssql");
???jdbc/mssql
这里的信息是否完整?