Skip to content

Commit 23e00eb

Browse files
committed
fix character encoding issues for DB and HTTP [ci skip]
1 parent a98ed01 commit 23e00eb

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ SteVe is designed to run standalone, a java servlet container / web server (e.g.
3939
The following MySQL statements can be used as database initialization (adjust according to your setup):
4040

4141
```
42-
CREATE DATABASE stevedb;
42+
CREATE DATABASE stevedb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
4343
GRANT ALL PRIVILEGES ON stevedb.* TO 'steve'@'localhost' IDENTIFIED BY 'changeme';
4444
GRANT SELECT ON mysql.proc TO 'steve'@'localhost' IDENTIFIED BY 'changeme';
4545
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--
2+
-- update the character set for existing installations.
3+
4+
-- mysql will refuse to change the character set of tables with foreign key relationships,
5+
-- so we disable foreign key checks (we could also first drop FKs and after changes insert FKs again).
6+
-- but then, to ensure data integrity, we should block other access to these tables. hence, the lock tables.
7+
--
8+
-- and also we cannot touch book keeping table "schema_version" of flyway,
9+
-- since it will be in use during the migration.
10+
--
11+
-- https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
12+
-- http://stackoverflow.com/a/766996
13+
--
14+
15+
LOCK TABLES
16+
address WRITE,
17+
charge_box WRITE,
18+
connector WRITE,
19+
connector_meter_value WRITE,
20+
connector_status WRITE,
21+
ocpp_tag WRITE,
22+
reservation WRITE,
23+
settings WRITE,
24+
`transaction` WRITE,
25+
`user` WRITE;
26+
27+
SET FOREIGN_KEY_CHECKS = 0;
28+
29+
ALTER TABLE address CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
30+
ALTER TABLE charge_box CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
31+
ALTER TABLE connector CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
32+
ALTER TABLE connector_meter_value CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
33+
ALTER TABLE connector_status CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
34+
ALTER TABLE ocpp_tag CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
35+
ALTER TABLE reservation CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
36+
ALTER TABLE settings CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
37+
ALTER TABLE `transaction` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
38+
ALTER TABLE `user` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
39+
40+
SET FOREIGN_KEY_CHECKS = 1;
41+
42+
UNLOCK TABLES;

src/main/resources/webapp/WEB-INF/views/00-header.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%@ page contentType="text/html" pageEncoding="utf-8" language="java" trimDirectiveWhitespaces="true" %>
1+
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" trimDirectiveWhitespaces="true" %>
22
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
33
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
44
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>

0 commit comments

Comments
 (0)