The fact is that having deployed an application on a hosting, I ran into an encoding problem, everywhere I use UTF-8, I traced all the way and found that the controller comes into the database (mySQL) ????? . The whole project is on annotations (Spring), in the @Configuration class I connect to the database:

 @Bean public DataSource dataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUrl("jdbc:mysql://localhost:3306/*******"); ds.setUsername("root"); ds.setPassword("*******"); return ds; } 

How to specify the encoding when connecting jdbc: mysql: // ... / ...? CharacterEncoding = UTF-8, only not in the xml, but in the bin?

  • specify in jdbc url - etki
  • .... I do not know how - user_Kyrt
  • you wrote yourself? characterEncoding = UTF-8 - Bohdan Korinnyi
  • ds.setUrl ("jdbc: mysql: // localhost: 3306 / name_db? characterEncoding = UTF-8): - Bohdan Korinnyi
  • you can also create a database with a different encoding and the problem is not at all in customization ... - Bohdan Korinnyi

1 answer 1

in datasource ds.setUrl("jdbc:mysql://localhost:3306/name_db?characterEnco‌​ding=UTF-8)