Tomcat配置(100分)

  • 主题发起人 主题发起人 saisi
  • 开始时间 开始时间
S

saisi

Unregistered / Unconfirmed
GUEST, unregistred user!
jsp通过jdbc-odbc来连接access时出现如下错误:
java.lang.NullPointerException
at org.apache.jsp.user$jsp._jspService(user$jsp.java:95)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:484)
 
java的错误抛出来就是一大堆,不知道是否可能从这些错误就能看出你的代码是怎样写的?
你何不把代码贴出来呢?
 
java.lang.NullPointerException是这问题
不是ODBC连接的问题,是你取出数据后,对变量进行操作出错,这个变量值为NULL,你具体查一下就知道了
at org.apache.jsp.user$jsp._jspService(user$jsp.java:95)
 
TO SNJAT:
我的代码如下:
bean:
package test;
import java.sql.*;
import java.sql.*;
public class user {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:sunshine";
private Connection conn = null;
private Statement stmt = null;
ResultSet rs = null;
public user() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("user(): " + e.getMessage());
}
}

public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr,"Admin","");
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("user.executeQuery: " + ex.getMessage());
}
return rs;
}

public void executeUpdate(String sql) {
stmt = null;
rs=null;
try {
conn = DriverManager.getConnection(sConnStr);
stmt = conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(SQLException ex) {
System.err.println("user.executeQuery: " + ex.getMessage());
}
}
public void closeStmt(){
try{
stmt.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
public void closeConn(){
try{
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
}
jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>我的FAQ !</title>
</head>
<body>
<p><b>这是我的FAQ!</b></p>
<%@ page import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.user" />
<%
ResultSet RS = null;
RS = workM.executeQuery("SELECT * FROM USER");
while(RS.next()){
out.print("<LI>Name: "+RS.getString("name")+"</LI>");
out.print("<LI>Password: "+RS.getString("password")+"</LI>");
}
RS.close();
%>
 
SELECT * FROM USER");这句SQL对吗?在数据库中测一下
name字段是否相符
password
 
对的。
我在JAVA中是能够得到结果的。
 
在执行user.executeQuery(sql)时出现异常的
 
你的代码我拷贝过来测试过,没有问题。请检查你的ODBC数据源sunshine连接到包含有表user的
Access数据库
我的测试环境:JBuilder7+Tomcat4/Weblogic7
 
肯定有。
但是我在TOMCAT的配置文件SERVER.XML中去掉关于JdbcOdbcDriver的Realm元素后,
启动TOMCAT时失败。
 
哦,我也碰到过这种情况。只要在配置ODBC时配系统DSN就可以了。
 
thank you,kevin_zhou.
It is so easy...
 
后退
顶部