创建mysql数据库并指定编码

xplanner的readme.txt里有句话
“XPlanner has only been tested on mysql 4.x, myslq 5.0, Tomcat 5.x, java 1.4, windows and linux.”
不过我用的环境是,JDK1.5+tomcat5.5+mysql5


安装jdk、tomcat、mysql省略......


  #mysqladmin -u root password centos
  # mysql -u root -p
  Enter password: 
  mysql> create database xplanner character set utf8;
  mysql>create user xplauser identified by 'xplanner';
  mysql>grant all privileges on xplanner.* to xplauser@'%' identified by 'xplanner' with grant option;
  mysql>grant all privileges on xplanner.* to xplauser@'localhost' identified by 'xplanner' with grant option;
  mysql> flush privileges;

    hibernate.dialect=com.technoetic.xplanner.db.hibernate.XPlannerMySQLDialect
  hibernate.connection.driver_class=com.mysql.jdbc.Driver
  hibernate.connection.url=jdbc:mysql://localhost/xplanner?autoReconnect=true&useUnicode=true&characterEncoding=UTF8
  hibernate.connection.username=xplauser
  hibernate.connection.password=xplanner


步骤: 
1、下載 xplanner-0.7b7b-war.zip 
可以到http://ftp.heanet.ie/disk1/sourceforge/x/xp/xplanner/ 去下载,不要下载xplanner-0.7b7-war.zip,要下载xplanner-0.7b7b-war.zip

2、xplanner/web-inf/classes/xplanner.properties 跟 xplanner-custom.properties成相应的数据库连接

3、xplanner-0.7b7-war/ant create.db.schema.script会在installer目录下生成文件

4、將 installer 目录下的 hibernate_schema.sql 的資料跑一遍,会在数据库产生需要的表 
这个脚本文件每条 语句都没有用分号包住,还要自己修改成mysql可执行的格式

5、xplanner-0.7b7-war/ant bootstrap 建立 sysadmin 的資料進 mysql

6、删除 /WEB-INF/classes/patches 下所有資料

7、 xplanner Copy 到 Tomcat

8、替换内容 
打开 /xplanner/WEB-INF/classes/spring-beans.xml 
找到 bean id="metaRepository" 
替换成如下样子

<property name="repositories"> 
<bean class="java.util.HashMap"> 
<constructor-arg> 
<map>.....</map> 
</constructor-arg> 
</bean> 
</property>

就是把<map>...</map>用外面两个属性包住.

9、foot.jsp页面报错,JSP页面报错其实挺简单的,就是引号里面套了个引号,把里面的引号转义下就OK了。

MYSQL中文乱码问题: 

1: 更改xplanner-custom.properties 
hibernate.connection.url=jdbc:mysql://localhost/xplanner?autoReconnect=true&useUnicode=true&characterEncoding=GBK 

2: 新增数据库,编码为GBK 
CREATE DATABASE `xplanner` DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;

其实只要存取编码一致,都设置成UTF8的也没有问题! 


汉化问题: 

把汉化文件 http://runthu.javaeye.com/topics/download/942e7cab-b1f3-3376-bd00-8c804f602983 覆盖到xplanner/WEB-INF/classes目录下。

原文地址:https://www.cnblogs.com/adolfmc/p/4749233.html