Java – spring MVC hibernate encoding / multi line SQL import

I'm studying spring MVC,

When the project starts, I have set up the database to import the default SQL and use hibernate to configure hibernate hbm2ddl. import_ files. import. The data in SQL is encoded in 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,'About Us',N'ჩვენს
 შეს�ხებ',b'1','/article/view/1',3,1).

Solution

>Ensure that the jdbc driver is set to use UTF-8:

JDBC: MySQL: / / dbname useunicode = true ampere; Characterencoding = UTF-8 > in persistence In XML, set the hibernate connection character set:

< property name =“hibernate.connection.charSet”value =“UTF-8”/>

If your resources / import The SQL file is multiline. Please add:

<property 
  name="hibernate.hbm2ddl.import_files_sql_extractor"
  value="org.hibernate.tool.hbm2ddl.MultipleLinessqlCommandExtractor" 
/>

Or for spring boot, in application In properties:

spring.jpa.properties.hibernate.connection.charSet=UTF-8
spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinessqlCommandExtractor
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>