public ResultSet getResultSet(String strSql)
{
        Connection conn = null;
        
    try{
           Class.forName("com.mysql.jdbc.Driver");
           conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/oost?user=root&password=&useUnicode=true&characterEncoding=8859_1");
          if(conn!=null) System.out.println("Connection Successful!");
      }catch(Exception e){
           e.printStackTrace();
           System.out.println("Error Trace in getConnection() : " + e.getMessage());
     }     Statement stm;
    ResultSet rs = null;
    try
{
stm=conn.createStatement();
// rs = stm.executeQuery(strSql);
System.out.println("creteStatement Success");

}
catch (SQLException ex)
{
ex.printStackTrace();
System.out.println("dbTrans.executeQuery:"+ex.getMessage());
}       return rs;
}以上代码用javac执行正常,在eclipse中调试正常,惟独是在浏览器里浏览一去到stm=conn.createStatement();
这句就出错,到底什么原因,救救我吧
环境:jdk1.502 + tomcat5.5

解决方案 »

  1.   

    HTTP Status 500 -type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.exceptionorg.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causejava.lang.NullPointerException
    org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:106)
    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:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
      

  2.   

    如果你后台没有输出Connection Successful!就是你的问题咯
      

  3.   

    conn is null, so when u call conn.createStatement(), throws NullPointerException
    maybe there is sth wrong when establish your connection
      

  4.   

    报空指针异常,楼主就找找看哪里定义了变量,没有NEW哈,很容易找的吧。
    java.lang.NullPointerException
    org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:106)
    到TOMCAT的WORK文件夹中找到这个类看一下就OK