当前位置: 代码迷 >> Java相关 >> java.lang.NullPointerException!异常
  详细解决方案

java.lang.NullPointerException!异常

热度:10256   发布时间:2013-02-25 21:48:24.0
java.lang.NullPointerException!!!错误
java代码
***********************************************************************************************************

 @WebServlet("/GetSearchResultByTableFormat")
public class GetSearchResultByTableFormat extends HttpServlet {
private static final long serialVersionUID = 1L;
   
 
public GetSearchResultByTableFormat() {
conn_init(); //出错行26
}
Connection conn;
Statement st;
int currentPage; //当前页号
int pageSize; //每页显示记录条数
int totalPage; //总共页数
int previousPage; //前一页页号
int nextPage; //下一页页号
int columnCount; //总共列数
int totalRecord; //总记录数
String tableTitle; //大标题,这个的下面才是显示的内容
String editUrl; //编辑页面的URL
String delUrl; //删除页面的URL
String viewUrl; //查看指定记录URL
String currentPageUrl;//当前页面的url地址
boolean verify = false; //是否当前记录验证
String verifyURL; //记录的验证地址
boolean sort;//是否需要动态排序
int sortType;//排序类型,一为升序,2为降序
String desc="▼";
String asc="▲";
String sortColumn;//排序的字段
boolean search;//是否显示查询功能
String searchType;
String searchCondition;
/******************************初使化数据库链接******************************/
private void conn_init() {
setConnection();
setStatement(); //出错行55  
 }

private void setConnection() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@192.168.1.201:1521:orcl"; 
String user="upload"; 
String password="eap"; 
Connection conn= DriverManager.getConnection(url,user,password); 

System.out.print("success!");

} catch (Exception e) {
e.printStackTrace();
}
}

private void setStatement() {
try {
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); // 出错行75

} catch (SQLException e) {
e.printStackTrace();
}
}
/*****************************初使化数据库链接OK*****************************/
 


**************************************************************************************************************



错误信息!!!!

*************************************************************************************************************
success!2011-10-28 8:47:40 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [jsp] in context with path [/dxxt] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at com.java.GetSearchResultByTableFormat.setStatement(GetSearchResultByTableFormat.java:75)
at com.java.GetSearchResultByTableFormat.conn_init(GetSearchResultByTableFormat.java:55)
at com.java.GetSearchResultByTableFormat.<init>(GetSearchResultByTableFormat.java:26)
at org.apache.jsp.jsp.page.page0_jsp._jspService(page0_jsp.java:80)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Tue Oct 23 20:13:13 CST 2018
  • 最近登录:Tue Oct 23 20:13:13 CST 2018
  • 最近登录:Tue Oct 23 20:13:13 CST 2018
  • 最近登录:Tue Oct 23 20:13:13 CST 2018
  • 最近登录:Tue Oct 23 20:13:13 CST 2018