Answer the question
In order to leave comments, you need to log in
Why is nothing displayed when querying the database if a search is made by value from "Russian" letters?
I make a query to the database on the name column, and if the name consists of English. letters, then everything is displayed. If name consists of Russian. letters, then nothing comes:
The first few lines from the database:
Request and output code:
ResultSet resultSetManufacturerID = DBHandler.executeQuery("SELECT ID FROM manufacturer WHERE Name = '"+ManufacturerTitle+"'");
String manufacturerID = null;
try {
while (resultSetManufacturerID.next()) {
manufacturerID = resultSetManufacturerID.getString(1);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
System.out.println("manufacturerID: " + manufacturerID);
public static ResultSet executeQuery(String sql) {
ResultSet resultSet = null;
System.out.println(sql);
try {
PreparedStatement preparedStatement = connection.prepareStatement(sql);
if (sql.contains("SELECT")) {
resultSet = preparedStatement.executeQuery();
} else {
preparedStatement.executeUpdate();
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return resultSet;
}
Answer the question
In order to leave comments, you need to log in
First, you should not use string concatenation to form sql queries. Secondly, you should make sure that the string encoding matches the database encoding.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question