JSP环境中安装MySQL管理jspmyadmin过程遇到的问题及解决方法 .

迅恒数据中心

在使用Mysql数据库时,我用的是jspmyadmin的图形管理界面来管理该数据库,我的
步骤是:
第一步:下载jspmyadmin,网址:http://sourceforge.net/projects/jspmyadmin/
页面

第二步:将下载的jspmyadmin压缩文件(jspmyadmin0.6.zip)解压后,将该文件夹全部复制到网站服务器Tomcat的Webapps目录下,因此它的路径为D:/Tomcat 6.0/webapps/jspmyadmin

第三步:经过上面的设置后,如果在IE浏览器的地址栏中输入http://localhost:8080/jspmyadmin/,则会发现jspmyadmin管理接口无法正常显示,这是因为还没有修改jspmyadmin数据库状态设置文件config.inc.jsp,由于Mysql数据库默认的连接端口是3306,因此打开jspmyadmin文件夹下的config.inc.jsp文件后修改第13行的程序代码port=3306。

第四步:但此时重新在地址栏中输入http://localhost:8080/jspmyadmin/,又会出现
http status 500的错误,页面出现的代码为:
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: 43 in the jsp file: /lib.inc.jsp
Enumeration cannot be resolved
40: pageContext.setAttribute(PROPERTIES_REQUEST_KEY,myproperties,
pageContext.SESSION_SCOPE);
41: }
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );


An error occurred at line: 44 in the jsp file: /lib.inc.jsp
Syntax error on token "enum", invalid expression_r_r
41: }
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );
47: all.put( key, value );


An error occurred at line: 45 in the jsp file: /lib.inc.jsp
Syntax error on token "enum", delete this token
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );
47: all.put( key, value );
48: }


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError
(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError
(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.20 logs.
该问题的解决方法为:修改第lib.inc.jsp文件的43行:Enumeration enum = myproperties.propertyNames(); 中的enum改为enum_new,下面几行中也有几处enum,一并修改,注意不要改错了,只修改enum变量为enum_new;这主要是因为新版本的Jspmyadmin中enum已经变成关键字了,所以enum不能作为变量名,这里就是发生了变量名与关键字的冲突。

第五步:就在我们觉得快大功告成的时候,又出现了新的问题。同样我们在地址栏中输入访问的地址,打开的网页显示的代码如下:
Oops! an exception occurred.
The exception was: java.sql.SQLException: Invalid authorization specification: Access denied for user 'root'@'localhost' (using password: NO)
The exception class was : class java.sql.SQLException
我原来的解决方法是打开jspmyadmin文件夹下的config.inc.jsp文件,修改password=“我实际用的数据库的密码”,但是又出现新的问题:
Oops! an exception occurred.
The exception was: java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
The exception class was : class java.sql.SQLException
所以我个人认为jspmyadmin管理Mysql数据库,该数据库的密码必须改为空,以下为修改数据库密码的代码:
mysql->use mysql;
mysql->update mysql.use set password = password(‘’) where user=’root’;
mysql->flush privileges;
mysql->quit

以上代码都是命令,打开MySQL Command Line Client ,输入密码进入MysQL,就可以按上面的输入命令
这下在输入访问地址,成功的进入jspmyadmin 管理界面。

补充:修改jspmyadmin中文编码
打开Tomcat服务器的jspmyadmin 文件夹,找到其中的lib.inc.jsp文件并打开该文件.在第17行加上程序代码如下:contentType=”text/html;charset = gb2312”,也就是将第17行改成如下的程序代码:
<%@ page contentType=”text/html;charset=gb2312” language=”java” import=”java.text.*,java.sql.*,java.util.*,java.io.*,java.net.*,com.jspmyadmin,*” errorPage=”error..jsp” %>
在第21行按下Enter键空出一行,并加上如下程序代码:
Request,setCharacterEncoding(“gb2312”);
这样在jspmyadmin管理界面中输入中文字,中文字可以正常显示了。
 

 

另外:
使用了tomcat6.0,然后JspMyAdmin是从SourceGet上下载的
由于是不需要安装的版本,我就直接放到WebApps下面了,问题来了
能看到登陆画面,就是登陆了之后,进去的页面是混乱的。
后来找到原因了:
login.jsp
里面有一段:
String User="root";
String Pass=""; //****这一行是密码,要改了
String Host="localhost";
String Port="3306";
改动之后,立马就登陆成功了!!

 

如果出现500错误如:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 43 in the jsp file: /lib.inc.jsp
Enumeration cannot be resolved
40: pageContext.setAttribute(PROPERTIES_REQUEST_KEY,myproperties, pageContext.SESSION_SCOPE);
41: }
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );


An error occurred at line: 43 in the jsp file: /lib.inc.jsp
Syntax error on token "enum", delete this token
40: pageContext.setAttribute(PROPERTIES_REQUEST_KEY,myproperties, pageContext.SESSION_SCOPE);
41: }
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );


An error occurred at line: 44 in the jsp file: /lib.inc.jsp
Syntax error on token "enum", invalid Expression
41: }
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );
47: all.put( key, value );


An error occurred at line: 45 in the jsp file: /lib.inc.jsp
Syntax error on token "enum", delete this token
42: Hashtable all = new Hashtable();
43: Enumeration enum = myproperties.propertyNames();
44: while (enum.hasMoreElements()) {
45: String key= (String)enum.nextElement();
46: String value= myproperties.getProperty( key );
47: all.put( key, value );
48: }


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:443)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

在你的jsp页面上部<%@page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>之后加上下面这句<%@page import="java.util.Enumeration"%>就好了,使用类之前,要先引入那个类,这句话就是引入Enumeration这个类的

导入java.util.*;这个包,才有Enumerationenum这个变量是关键字,不能用他

在你的jsp中,
没有import需要的类:
<% @page import="java.util" %>

原来的JspMyadmin估计是1.4的基础上写的,到1.6时enum变成了关键字,所以我就参考Google搜索结果尝试自己修改了一下lib.inc.jsp,结果居然成功了。现将解决办法共享给大家:
1、修改第43行:Enumeration enum = myproperties.propertyNames(); 中的enum改为enum_new,下面几行中也有几处enum,一并修改,注意不要改错了,只修改enum变量为enum_new;
2、上述一处修改完毕后,再刷新浏览器,又报318行错误,因此修改318行,enumeration en = index.keys;为Enumeration,估计这里是作者把字母大小写给弄错了。
至此,整个文件修改完毕,刷新浏览器后,就出现了我们熟悉的PhpMyadmin界面了,当然,我们用的JspMyadmin是从PhpMyadmin修改过来的。

分类:IDC资讯 百度收录 必应收录