<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<HTML>
<Body>
<%
Connection con;
Statement sql;
ResultSet rs;
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
}
catch(class NotFoundExcepion e){}
try{ con=DriverManager.getConnection("jdbc:odbc:firm","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT*from students where shuxue>=25");
System.out.print("<Table Border>");
System.out.print("<form>");
System.out.print("<TR>");
System.out.print("<Td width="100">"+"xingming" +"</td>");
System.out.print("<Td width="50">"+"shuxuechengji" +"</td>");
System.out.print("</TR>");
while(rs.next()){
System.out.print("<td>");
System.out.print("<TD>"+rs.getString("xingming")+"</TD>");
System.out.print("<TD>"+rs.getInt("shuxue")+"</TD>");
System.out.print("</TR>");
}
System.out.print("</form>");
System.out.print("</Table>");
con.close();
}
catch(SQLException e){}
%>
</BODY>
</HTML>
报告如下错误:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:51: <identifier> expected
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
^
An error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:51: '{' expected
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
^
An error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:53: 'catch' without 'try'
catch(classNotFoundExcepion e){}
^
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:31: 'try' without 'catch' or 'finally'
try {
^
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:93: '}' expected
^
5 errors org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
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.请大虾们帮帮我 还是第一次连接数据库!!
<%@ page import="java.sql.*"%>
<HTML>
<Body>
<%
Connection con;
Statement sql;
ResultSet rs;
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
}
catch(class NotFoundExcepion e){}
try{ con=DriverManager.getConnection("jdbc:odbc:firm","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT*from students where shuxue>=25");
System.out.print("<Table Border>");
System.out.print("<form>");
System.out.print("<TR>");
System.out.print("<Td width="100">"+"xingming" +"</td>");
System.out.print("<Td width="50">"+"shuxuechengji" +"</td>");
System.out.print("</TR>");
while(rs.next()){
System.out.print("<td>");
System.out.print("<TD>"+rs.getString("xingming")+"</TD>");
System.out.print("<TD>"+rs.getInt("shuxue")+"</TD>");
System.out.print("</TR>");
}
System.out.print("</form>");
System.out.print("</Table>");
con.close();
}
catch(SQLException e){}
%>
</BODY>
</HTML>
报告如下错误:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:51: <identifier> expected
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
^
An error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:51: '{' expected
try{class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
^
An error occurred at line: 5 in the jsp file: /text/hehe.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:53: 'catch' without 'try'
catch(classNotFoundExcepion e){}
^
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:31: 'try' without 'catch' or 'finally'
try {
^
Generated servlet error:
D:\TOMCAT\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\text\hehe_jsp.java:93: '}' expected
^
5 errors org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
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.请大虾们帮帮我 还是第一次连接数据库!!
解决方案 »
- 浮动广告,在jsp中可以关闭,在html中为什么不能?
- 请问java自定义标签是为每一个请求(线程)创建一个实例吗?
- Action里面的sendRedirect(url)问题
- 我刚刚安装好JSP的运行环境,我该把写好JSP程序,放在哪个文件里,才可以运行呢??
- java 调用有返回参数的存储过程
- 送分 新手求教一段JS代码
- 简单问题!
- struts2拦截器里能不能直接获取一个实体类对象,就像action里一样?
- 请教一下关于java中的float类型的数据相加出现的数据误差问题。
- 怎么实现网页的内容刷新
- ^^^^^^++++求带复选框的树型菜单的完整实现代码,动态加载为佳,我是在SPRING下开发
- 加密算法问题
Connection con;
Statement sql;
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
} catch (ClassNotFoundException e) {
}
try {
con = DriverManager.getConnection("jdbc:odbc:firm", "", "");
sql = con.createStatement();
rs = sql.executeQuery("SELECT*from students where shuxue>=25"); System.out.print("<Table Border>");
System.out.print("<form>");
System.out.print("<TR>");
System.out.print("<Td width="100">"+"xingming" +"</td>"); System.out.print("<Td width="50">"+"shuxuechengji" +"</td>");
System.out.print("</TR>");
while (rs.next()) {
System.out.print("<td>");
System.out.print("<TD>" + rs.getString("xingming") + "</TD>");
System.out.print("<TD>" + rs.getInt("shuxue") + "</TD>");
System.out.print("</TR>");
}
System.out.print("</form>");
System.out.print("</Table>"); con.close();
} catch (SQLException e) {
}
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)可是我的JAVA_HOME 都配置好了
还有就是找不到继承的类
Class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
}
catch (ClassNotFoundException e)
请大虾们 帮帮 !!谢谢!
不是:"sun.jdbc.odbc.jdbcOdbcDriver"
你把JdbcOdbcDriver 写成 jdbcOdbcDriver
"sun.jdbc.odbc.jdbcOdbcDriver"
为
"sun.jdbc.odbc.JdbcOdbcDriver"
再试一下.