我想在mysql中保存一个阿拉伯语字符,在我的csv文件中我有阿拉伯语和英语字符。
当我显示控制台日志时,我可以看到带有阿拉伯字符的字符串,但在mysql中,我看到了“??”字符
如果我的csv文件、数据库和表都是utf-8编码
我还在application.properties中添加了以下内容:
spring.datasource.url=jdbc:mysql://localhost:3306/contacts?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=
我使用的是springbatchversion4,带有简单的csv到mysql
我必须补充什么?
附加代码:
@Bean
public FlatFileItemReader<Csv> fileReader(@Value("${input}") Resource in) throws Exception {
return new FlatFileItemReaderBuilder<Csv>()
.name("file-reader")
.resource(in)
.targetType(Csv.class)
.linesToSkip(1)
.delimited().delimiter(";").names(new String[]{"Name","Email","UID","Username","Phone","Location","Birthday","Gender"})
.build();
}
@Bean
public JdbcBatchItemWriter<Contact> jdbcWriter(DataSource ds) {
return new JdbcBatchItemWriterBuilder<Contact>()
.dataSource(ds)
.sql("INSERT INTO contact (UID, name, username, gender, phone, email, birthday, location, country_id, city_id, state_id) VALUES (:uid, :name, :username, :gender, :phone, :email, :birthday, :location, :countryId, :cityId, :stateId)")
.beanMapped()
.build();
}
暂无答案!
目前还没有任何答案,快来回答吧!