This is my first time asking at StackOverFlow. I'm not good at English. Please excuse me.
I'm having a problem that my application is returning a strange character.
PlayStation\ufffd\ufffd4 Pro
It has to be like this:
PlayStation®4 Pro
I think '\ufffd' character represents this, 'REPLACE CHARACTER'.
My application is using jdk 1.6.
I found that when I change my application's jdk to 1.7, it prints the character correctly.
PlayStation®4 Pro
More Information
My application uses ibatis, and the problem is occurring after queryForObject.
public class A {
private String content;
public String getContent() {
return content;
}
}
A a = (A)queryForObject("mapper.getSomething", params);
return a;
// jdk1.6 - a.getContent() : PlayStation\ufffd\ufffd4 Pro
// jdk1.7 - a.getContent() : PlayStation®4 Pro
JDBC connection property is like this.
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://{IPADDRESS}/{DBNAME}?Unicode=true&characterEncoding=MS949&zeroDateTimeBehavior=convertToNull&socketTimeout=500000&connectTimeout=500000
More Information 2
- I tested without ibatis and others. Directly using jdbc connection, but the same result.
public class CharacterEncodeTest {
// JDBC driver name and database URL
static final String DB_URL = "jdbc:mysql://{IPADDRESS}/{DBTNAME}}?Unicode=true&characterEncoding=MS949&zeroDateTimeBehavior=convertToNull&socketTimeout=500000&connectTimeout=500000";
// Database credentials
static final String USER = "{USER}";
static final String PASS = "{PASSWORD}";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try {
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql = "SELECT * from TABLE";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while (rs.next()) {
//Retrieve by column name
String content = rs.getString("content");
//Display values
System.out.print("content: " + content);
// jdk1.6 : PlayStation\ufffd\ufffd4 Pro
// jdk1.7 : PlayStation®4 Pro
}
rs.close();
} catch (SQLException se) {
// something
} finally {
// something
}//end try
}
}
Question
The only difference is just changing jdk version.
What difference is the matter between jdk 1.6 and 1.7 about this problem?
Is there any solution to solve this problem in jdk 1.6?
No idea what \ufffd is, but the ® symbol is \u00ae: https://www.fileformat.info/info/unicode/char/00ae/index.htm