I have Hindi data in a MySQL database. See Next Image -

Now I want to get this data and display it on my JSP page, but when I try to get the data in my java code, I get the text in the following formate
UID= ????/??????????/????/?????/?????/Test upgrade/1
UID= ????/??????????/??????/??????/??????????/159/1
UID= ????/??????????/??????/??????/??????????/190/1
UID= ????/??????????/??????/??????/??????????/194/1
UID= ????/??????????/??????/???????/?????? (??.)/730/1
UID= ????/??????????/??????/???????/?????? (??.)/742/1/1
UID= ????/??????????/??????/???????/?????? (??.)/732/1
UID= ????/??????????/??????/??????/??????/98/8/1
UID= ????/??????????/??????/??????/??????/48/10/1
Turning to this question , I changed my database encoding to "utf8_unicode_ci", but still does not work. I wrote the following code to extract data
public void getDetails()
{
DBConnection bdConnection = new DBConnection();
java.sql.Connection connectionObject = null;
java.sql.ResultSet resultSetObject;
java.sql.PreparedStatement preparedStatementObj = null;
connectionObject = bdConnection.getDbConnection();
if (connectionObject != null)
{
String strQuery = "SELECT * FROM tbl_test_master";
try
{
preparedStatementObj=connectionObject.prepareStatement(strQuery);
resultSetObject = preparedStatementObj.executeQuery(strQuery);
while(resultSetObject.next())
{
String strUserId=resultSetObject.getString("user_id");
System.out.println("UID= "+strUserId);
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
Below is my "DBConnection" class -
public class DBConnection
{
public static Connection connectionObject;
public Connection getDbConnection()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
String strURL = "jdbc:mysql://xx.xx.xxx.xxx:xxxx/my_db?user=db_user&password=db_pass";
connectionObject = (Connection) DriverManager.getConnection(strURL);
System.out.println("Connection Successfull");
}
catch (Exception e)
{
System.out.println(e);
}
return connectionObject;
}
public void closeConnection(Connection connectionObj )
{
try
{
connectionObj.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
Thank..!
source
share