|
Java学习者论坛
我的系统是:
Red Hat Enterprise Linux Server 5
PHP Version 5.1.6
Apache 2.2
MySQL 5.0
Tomcat 5
mysql-connector-java-5.0.5-bin.jar (已經放Daotomcat的common\lib目录下)
我的程序如下:
<%@ page contentType="text/HTML;charset=gb2312" language="java" import="java.io.,java.sql.,java.util.Date"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="java.util.GregorianCalendar"%>
<%@ page import="java.util.,javax.Servlet." %>
<%@ page import ="java.io.OutputStreamWriter"%>
<%@ page import ="java.text.DecimalFormat,java.text.Format.*"%>
<%@ page import ="java.text.NumberFormat,java.io.PrintStream"%>
<%
Connection conn = null;
String url="",QueryStr="";
Statement stmt = null;
ResultSet rs = null;
String MySQL_IP = "192.180.15.1";
String MySQL_ID = "mht";
String MySQL_PW = "19951101";
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
// Class.forName("com.mysql.jdbc.Driver").newInstance();//使yong这一xing與上一行问题一样
url ="jdbc:mysql://"MySQL_IP"/basic?user="MySQL_ID"&password="MySQL_PW"&useUnicode=true&characterEncoding=gb2312";
conn = DriverManager.getConnection(url);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch(Exception e){
e.printStackTrace();
out.println(e);
}
String str="";
QueryStr="select * from station where TYPE='0' or TYPE='1' or TYPE='2'";
rs=stmt.executeQuery(QueryStr);
while(rs.next()){
str=rs.getString("STATION");
out.print(str);
}
if(rs != null) rs.close();
if(stmt != null) stmt.close();
if(conn != null) conn.close();
%>
問題是:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /sy1.jsp:36
33: }
34: String str="";
35: QueryStr="select * from station where TYPE='0' or TYPE='1' or TYPE='2'";
36: rs=stmt.executeQuery(QueryStr);
37: while(rs.next()){
38: str=rs.getString("STATION");
39: out.print(str);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(jasper5-compiler-5.5.17.jar.so)
org.apache.jasper.servlet.JspServletWrapper.service(jasper5-compiler-5.5.17.jar.so)
org.apache.jasper.servlet.JspServlet.serviceJspFile(jasper5-compiler-5.5.17.jar.so)
org.apache.jasper.servlet.JspServlet.service(jasper5-compiler-5.5.17.jar.so)
javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.17.jar.so)
root cause
java.lang.NullPointerException
org.apache.jsp.sy1_jsp._jspService(sy1_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(jasper5-runtime-5.5.17.jar.so)
javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.17.jar.so)
org.apache.jasper.servlet.JspServletWrapper.service(jasper5-compiler-5.5.17.jar.so)
org.apache.jasper.servlet.JspServlet.serviceJspFile(jasper5-compiler-5.5.17.jar.so)
org.apache.jasper.servlet.JspServlet.service(jasper5-compiler-5.5.17.jar.so)
javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.17.jar.so)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Apache Tomcat/5.5.17
請高手指教...
欢迎来到Java学习者论壇,转载请注明地址:http://www.javaxxz.com. |
|