Mis*_*ili 3 java mysql spring hibernate spring-mvc
我正在研究Spring MVC,
在项目启动时,我已设置database为sql
使用hibernate配置导入默认值hibernate.hbm2ddl.import_files.里面的数据import.sql用UTF-8.编码.
控制台输出
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - HHH000388:
Unsuccessful: INSERT INTO menu (id, DATE_CREATED, DATE_DELETED,
DATE_UPDATED, TITLE_ENG, TITLE_GEO, TITLE_RUS, ENABLED, PARENT_ID,
URL, SITE_ID, USER_ID) VALUES
ERROR:
org.hibernate.tool.hbm2ddl.SchemaExport - You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near '' at line 1
ERROR:
org.hibernate.tool.hbm2ddl.SchemaExport - HHH000388: Unsuccessful: (1,
'2015-09-10 12:00:00', NULL, NULL, 'About Us', N'ჩვენს
შეს�ხებ', 'About Us', b'1', NULL, '/article/view/1', 3,
1).
Run Code Online (Sandbox Code Playgroud)
Nei*_*gan 11
确保将JDBC驱动程序设置为使用UTF-8:
jdbc:mysql://dbname?useUnicode=true&characterEncoding=utf-8
在persistence.xml,设置hibernate连接字符集:
<property name="hibernate.connection.charSet" value="UTF-8"/>
如果您的resources/import.sql文件是多行的,请添加:
<property
name="hibernate.hbm2ddl.import_files_sql_extractor"
value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor"
/>
Run Code Online (Sandbox Code Playgroud)
或者用于Spring Boot,在application.properties:
spring.jpa.properties.hibernate.connection.charSet=UTF-8
spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2598 次 |
| 最近记录: |