| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 528 人关注过本帖
标题:[求助] 空指针错误 !!
只看楼主 加入收藏
yangyucn
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-22
收藏
 问题点数:0 回复次数:0 
[求助] 空指针错误 !!

package electric.dbs;
import electric.dbs.Dbnews;
import electric.dbs.news;
import java.util.Collection;
import java.util.ArrayList;
import java.sql.SQLException;
import java.sql.ResultSetMetaData;
import java.sql.ResultSet;
import java.util.Iterator;
import java.sql.*;
import javax.servlet.http.*;
import electric.electricUtils.*;

public class Newsdb {
public Newsdb() {
}
public int selectsql(int st)
{
String countSql="SELECT COUNT(*) FROM NEWS WHERE STATUS<>1";
Connection co=null;
ResultSet r = null;
PreparedStatement pstm = null;
int size=0;
int sizepa=0;
try {
co = DbConnectionManager.getConnection();
pstm = co.prepareStatement(countSql);
r = pstm.executeQuery();
while (r.next()) {
size = r.getInt(1);
sizepa=(int)size/st;
if(size%st>0)
{
sizepa=sizepa+1;
}
}

r.close();
r=null;
pstm.close();
pstm=null;
co.close();
co=null;
}

catch (SQLException sqle) {
System.err.println(sqle.getMessage()+"333");
}
return sizepa;
}
public Collection select(int step, int page) {
Collection coll = new ArrayList();
Connection con=null;
ResultSet rs=null;
PreparedStatement pstmt=null;
int tip = step * (page - 1);
try {
String sql="SELECT * FROM [NEWS] WHERE STATUS<>1";
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
System.out.print(tip);
if (tip <= 0) {
rs.beforeFirst();
} else {
if (!rs.absolute(tip)) {
rs.beforeFirst();
}
}
for (int i = 1; rs.next() && i <= step; i++) {
news news = new news();
news.setId(rs.getInt(1));
news.setMotif(rs.getString(2));
news.setKithepeople(rs.getString(3));
news.setContent(rs.getString(4));
news.setCreateDate(rs.getString(5));
news.setCreatepeople(rs.getInt(6));
news.setStatus(rs.getInt(6));

coll.add(news);
}

rs.close();
rs=null;
pstmt.close();
pstmt=null;
con.close();
con=null;
} catch (SQLException ex) {
System.out.println(ex.getMessage()+"666");
} finally {
return coll;
}
}
}


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
	electric.dbs.Newsdb.selectsql(Newsdb.java:34)
	org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:63)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
搜索更多相关主题的帖子: 指针 
2006-05-22 12:40
快速回复:[求助] 空指针错误 !!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028252 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved