Pulling data from the database. Faced the problem that Russian characters are in the form of question marks, although they are normally recorded in the table itself.

I connect to the database as follows:

Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:" + drivername + "://" + host + "/" + dbName + "?useUnicode=true&characterEncoding=utf8", User, Password); stat = connection.createStatement(); stat.execute("SET CHARACTER SET utf8"); stat.execute("SET NAMES utf8"); 

I pull it like this:

 String getdata = "Запрос"; PreparedStatement get = dbConnect.connection.prepareStatement(getdata); result = get.executeQuery(); while(result.next()) { ... } 

Encoding tables and the database itself - utf-8

  • one
    Where exactly do they come in the form of question marks? In the console? In the browser? In file? Most likely the problem is not in the request, but in the output device. - rjhdby
  • @rjhdby when retrieving in the servlet already obtained question marks. - Tsyklop

0