Background:
Myeclipse character encoding GBK
Oracle Database character encoding GBK
The character encoding UTF-8 that inserts content from a third party using the webservice Interface
Problem description:
Pre-compiled by java PreparedStatement to enter the insert operation, run SQL exception, baidu character encoding problem, after several transcoding methods is still fruitless, the final work und
Work und:
The insert statement is used to concatenate an SQL statement. Because the current myeclipse environment is GBK encoded, the Chinese characters in the inserted statement are converted to GBK encoding by default. The insert operation is normal.
The concatenated SQL statement is as follows:
- String SQL ="Insert into t_ivr_jobs_info_bak (JOBID, JOBTYPE, JOBAREA, JOBINFO) values ("+ JobId +",'"+ JobType +"','"+ JobCity +"','"+ JobInfo +"')";
Summary
PreparedStatement. setString (index, str); should be directly connected to the database. In this process, the str character encoding is still UTF-8. If no conversion is made, an exception occurs when the database is directly inserted. The encoding format is inconsistent.
After splicing the preceding SQL statements, the variables are displayed in the current environment, which is converted to the GBK format by default. Therefore, the encoding inconsistency is avoided when inserting the variables,
However, you cannot bind variables to improve performance. However, sometimes performance is not the most important thing.