I have issue with Cyrillic character in database, and usage it java spring.
I create my database in next way:
create database dbname
character set utf8
collate utf8_general_ci;
Example database table: (created automatically):
@Entity(name = "words")
public class Words {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "word")
private String word;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
}
Save entity way:
@Repository
public interface WordRepository extends JpaRepository<Word, Long> {
}
+
@Service
public class WordService{
@Autovired
private WordRepository wordRepository;
public saveAll(List<Word> wordList){
wordRepository.saveAll(wordList);
}
}
application.properties :
#Database settings
spring.datasource.url=jdbc:mysql://localhost:3306/dbname?useUnicode=yes&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.datasource.tomcat.connection-properties=useUnicode=true;characterEncoding=utf-8;
spring.datasource.sql-script-encoding=UTF-8
But, in result, when I save in database Cyrillic characters, all shows as '?'.
What else I must to do for resolve this?
Iterable– Valentyn Hruzytskyi Aug 31 '18 at 16:11saveAll(Iterablevar1); extending from CrudRepository interface