免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1582 | 回复: 1
打印 上一主题 下一主题

jsp链接mysql的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-10 17:37 |只看该作者 |倒序浏览
我安装了mysql-5.1 server和tomcat,以及kata-connector和mysql-connector-java

已经能完好的解析这个文件

****************************************************
<%
Runtime lRuntime = Runtime.getRuntime();

out.println("***BEGIN MEMORY STATISTICS***<br />");
out.println("Free Memory:"+lRuntime.freeMemory()/1024/1024+"M<br/>");
out.println("Max Memory:"+lRuntime.maxMemory()/1024/1024+"M<br/>");
out.println("Total Memory:"+lRuntime.totalMemory()/1024/1024+"M<br/>");
out.println("Available Processors:"+lRuntime.availableProcessors()+"<br/>");
out.println("***END MEMORY STATISTICS***");
%>
****************************************************

将如下文件传送到htdocs下,却不能显示

****************************************************

<%@ page language="java" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %>

<%

String driverName="com.mysql.jdbc.Driver";

String userName="root";

String userPasswd="";

String dbName="test";

String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;

Class.forName("com.mysql.jdbc.Driver").newInstance();
try
{
        Connection connection=DriverManager.getConnection(url);

        out.println(" O K !");

        connection.close();
}
catch( Exception e )
{
        out.println( "connent mysql error:" + e );
}

%>

****************************************************

报告

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:

An error occurred at line: 6 in the generated java file
Only a type can be imported. com.mysql.jdbc.Driver resolves to a package

Stacktrace:
        org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
        org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
        org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

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

检查日志却发现没有错误提示

tail /usr/local/apache2/logs/access_log
192.168.1.10 - - [10/Nov/2009:16:28:32 +0800] "GET /test.jsp HTTP/1.1" 200 154
192.168.1.10 - - [10/Nov/2009:17:08:47 +0800] "GET /test.jsp HTTP/1.1" 200 154
192.168.1.10 - - [10/Nov/2009:17:08:57 +0800] "GET /test_mysql.jsp HTTP/1.1" 404 997
192.168.1.10 - - [10/Nov/2009:17:17:43 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 2163
192.168.1.10 - - [10/Nov/2009:17:18:19 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 2163
192.168.1.10 - - [10/Nov/2009:17:18:22 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 3089
192.168.1.10 - - [10/Nov/2009:17:19:01 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 2163
192.168.1.10 - - [10/Nov/2009:17:19:39 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 2163
192.168.1.10 - - [10/Nov/2009:17:19:42 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 3089
192.168.1.10 - - [10/Nov/2009:17:19:43 +0800] "GET /test_mysql.jsp HTTP/1.1" 500 2163

论坛徽章:
0
2 [报告]
发表于 2009-11-11 10:18 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP