| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1026 人关注过本帖
标题:连接Oracle时出现异常
只看楼主 加入收藏
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
 问题点数:0 回复次数:8 
连接Oracle时出现异常

我用eclipse+myeclipse+tomcat建了3个文件,在Oracle中建了一个表,然后运行文件,但是连接Oracle时出现异常,
异常如下:

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
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.12


我已将ojdbc14.jar放到了C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\myjsp\WEB-INF\lib下;

C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib下,
可还是出现同样的异常,
是不是要配置环境变量,还是要在eclipse里添加、配置什么呢?

感激不尽!!

[此贴子已经被作者于2006-6-24 13:24:56编辑过]

搜索更多相关主题的帖子: Oracle 
2006-06-24 12:33
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 

下面是3个文件的代码,大家看看是哪里有错:
index.html:
<html>
<head>
<title>留言板</title>
</head>
<body bgcolor="#ccc231" vlink="#000000" alink="#666666">
<DIV align="center">
<p><FONT size="7">
<b><font size="+6"></font></b>
</FONT>
</p>
<FORM method="post" action="index.jsp">
<TABLE width="75%" align="center" border=1>
<TR>
<TD width="30%">
<div align="right">姓名:</div>
</TD>
<TD width="70%">
<INPUT type="text" name="name">
</TD>
</TR>
<TR>
<TD width="30%">
<DIV align="right">电子邮件:</DIV>
</TD>
<TD width="70%">
<INPUT type="text" name="email">
</TD>
</TR>
<TR>
<TD width="30%">
<div align="right" >个人主页地址:</div>
</TD>
<TD width="70%">
<TEXTAREA name="body" rows="5" cols="30"></TEXTAREA>
</TD>
</TR>
<TR>
<TD width="30%">&nbsp;</TD>
<TD width="70%">&nbsp;</TD>
</TR>
<TR>
<TD width="30%">&nbsp;</TD>
<TD width="70%">
<TABLE width="75%">
<TR>
<TD>
<INPUT type="submit" name="send" value="提交">
</TD>
<TD>
<INPUT type="reset" name="reset" value="重置">
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
<hr>
</DIV>
</body>
</html>

index.jsp:
<html>
<head>
</head>
<body>
<%@ page language="java" import="java.sql.*;"%>
<%@ page contentType="text/html;charset=gb2312"%>
<jsp:useBean id="sqlbean" class="hh.Sql_data" scope="session" />
<%! String name,email,url,body,sql;%>
<%
name=request.getParameter("name");
email=request.getParameter("email");
url=request.getParameter("url");
body=request.getParameter("body");
if(name!=""&&email!=""&&body!="")
{
sql="insert into guestbook (name,email,url,body) values ('"+name+"','"+email+"','"+url+"','"+body+"')";
sqlbean.executeInsert(sql);
}
else
{
out.print("<b><font color=red>Sorry,Please enter your name,email,and body!!!</font></b>");
}
%>
<%
ResultSet RScount=sqlbean.executeQuery("SELECT * FROM guestbook");
int i=0;
while(RScount.next())
{
i++;
}
%>
<%--<p><a name=see><b>Now,<%=RScount %>Records.</b></a></p> --%>
<p><b>现在有<%=i%>条记录</b></p>
<%
RScount.close();
i=0;
%>
<p>&nbsp;</p>
<%
ResultSet RS=sqlbean.executeQuery("select * from guestbook");
while(RS.next())
{
name=RS.getString("name");
email=RS.getString("email");
url=RS.getString("url");
body=RS.getString("body");
%>
<table border=1 width=80%>
<tr>
<TD width=30%>昵称:</TD><TD width=70%><%=name%></TD>
</tr>
<TR>
<TD width=30%>电子邮件:</TD><TD width=70%><a href="maito:<%=email%>"><%=email%></a></TD>
</TR>
<TR>
<TD width=30%>个人主页地址:</TD><TD width=70%><a href="<%=url%>"><%=url%></a></TD>
</TR>
<TR>
<TD width=30%>内容:</TD><TD width=70%><%=body%></TD>
</TR>
</table>
<hr>
<%
}
RS.close();
%>
</body>
</html>

package hh;
import java.sql.*;
public class Sql_data {

String sDBDriver="oracle.jdbc.driver.OracleDriver";
String sConnStr="jdbc:oracle:thin:@aa-52:1521:Grace";
Connection conn=null;
ResultSet rs=null;
public Sql_data()
{
try
{
Class.forName(sDBDriver);
}
catch(ClassNotFoundException e)
{
System.err.println("sql_data():"+e.getMessage());
}
}
public void executeInsert(String sql)
{

try
{
conn=DriverManager.getConnection(sConnStr,"syetem","ffffff");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.out.println("sql_data.executeUpdate:"+ex.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
conn=DriverManager.getConnection(sConnStr,"system","ffffff");
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeQuery:"+ex.getMessage());
}
return rs;
}
public void executeDelete(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr,"system","ffffff");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeDelete:"+ex.getMessage());
}
}

}

表:guestbook:
SQL> desc guestbook
名称 是否为空? 类型
----------------------------------------- -------- --------------------
NAME NOT NULL VARCHAR2(20)
EMAIL NOT NULL VARCHAR2(30)
URL VARCHAR2(50)
BODY VARCHAR2(200)


大家帮下忙啊

[此贴子已经被作者于2006-6-24 22:54:10编辑过]

2006-06-24 13:29
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
找到了一个错误后,再次运行文件,现在又出现了另外的异常了:

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: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:561)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:1792)
org.apache.catalina.loader.WebappClassLoader.findResource(WebappClassLoader.java:944)
org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1161)
javax.xml.parsers.SecuritySupport12$4.run(SecuritySupport12.java:119)
java.security.AccessController.doPrivileged(Native Method)
javax.xml.parsers.SecuritySupport12.getResourceAsStream(SecuritySupport12.java:112)
javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:263)
javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:169)
javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:139)
org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:129)
org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:112)
org.apache.jasper.compiler.JspConfig.init(JspConfig.java:213)
org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:229)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:207)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.12


这是什么问题呢?
2006-06-24 14:41
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
收藏
得分:0 

楼上的异常应该是一些很基本的异常吧
一个是JasperException: Unable to compile class for JSP
不能为JSP编译类异常,是不是你的JDK没有配置好?
二是NullPointerException
空指针异常,是不是你使用了没有初始化的对象


可惜不是你,陪我到最后
2006-06-24 14:44
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 

我到现在还没下载到一个完整的Oracle哭一下


淘宝杜琨
2006-06-24 15:16
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
大家帮忙看一下我的环境变量是否有问题:

用户变量:
classpath:
.;C:\Program Files\Java\jdk1.5.0_06\lib;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\jsp-api.jar;

JAVA_HOME:
C:\Program Files\Java\jdk1.5.0_06

path:
C:\Program Files\Java\jdk1.5.0_06\bin


系统变量:
path:
D:\oracle\ora92\bin;C:\Program Files\Java\jdk1.5.0_06\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
2006-06-24 18:11
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
把环境变量改了之后,异常又变成这样:

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
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

root cause

java.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs.


Apache Tomcat/5.0.12



这又是什么问题啊??

[此贴子已经被作者于2006-6-24 20:57:46编辑过]

2006-06-24 20:54
yangwudong
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:244
专家分:0
注 册:2005-8-18
收藏
得分:0 
你加javax.servlet.jar的包了吗?给工程!

别做程序了,给你们一个赚钱的秘诀。做豆腐;if 做硬了 then 卖豆腐干;if 做稀了 then 卖豆腐花;if 太稀了 then 卖豆浆;if 豆腐卖不动了放几天 then 卖臭豆腐; else if 还卖不动放坏了 then 卖腐乳;
2006-06-24 21:20
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
现在没有异常了,但是却出现了一个我无法理解的错误,脑袋都想破了,也没解决得了:

就是那个javabean(Sql_data.java)中的public void executeInsert(String sql)
方法它不执行,每次运行文件时,MyEclipse的Console都显示信息:sql_data.executeUpdate:ORA-01017: invalid username/password; logon denied

可是,public ResultSet executeQuery(String sql)和public void executeDelete(String sql)的username/password 也都是"syetem","ffffff" 呀,却能够正常调用,这究竟是怎么回事呀??

愁死我了!

大家帮忙分析一下是哪里的问题呀,谢谢了!!

2006-06-24 23:04
快速回复:连接Oracle时出现异常
数据加载中...
 
   



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

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