jsp连接acess数据库时遇到的问题,在线等待

liandliu 2006-02-08 01:27:05
tomcat运行成功并且jsp测试成功,odbc数据源设置完成,源程序如下:

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection conn=java.sql.DriverManager.getConnection

("jdbc:odbc:text");
java.sql.Statement stmt=conn.createStatement();
String sql="select * from text1";
java.sql.ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) { %>
第一个字段内容为:<%=rs.getString(1)%>
第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%System.out.print("数据库操作成功");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

发生以下错误

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.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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

...全文
101 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
infowain 2006-02-08
  • 打赏
  • 举报
回复
只要设置JAVA_HOME就行了,CLASSPATH可以不用设置
liandliu 2006-02-08
  • 打赏
  • 举报
回复
JAVA_HOME=E:\lif\j2sdk1.4.1_02;
CLASSPATH=E:\lif\j2sdk1.4.1_02\lib\tools.jar;
E:\lif\j2sdk1.4.1_02\lib\dt.jar;
E:\lif\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
PATH=E:\lif\j2sdk1.4.1_02\bin;

这些不懂,基本上照样子画的。
JDK和TOMCAT都在E:\lif下。
linda_gj 2006-02-08
  • 打赏
  • 举报
回复
看上去好像是没有把配置的JDK路径放到CLASS_PATH, 和JAVA_HOME里面呀。
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

要不就是路径写的不一致。对应不上。
bionergy 2006-02-08
  • 打赏
  • 举报
回复
应该是没有找到jdk的问题
在tomcat安转目录下的bin\startup.bat文件里面加上一句
set java_home=你的jdk路径
试试看
sheep219 2006-02-08
  • 打赏
  • 举报
回复
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

你JAVA_HOME 配好了没?有没有把dt.jar和tool.jar放入classpath中
liandliu 2006-02-08
  • 打赏
  • 举报
回复
HTTP Status 500 -

62,629

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧