java - MySQL - question marks -
when inserting app chinese characters written db '???'. needless works fine within built in command line mysql client.
connection string:
--user-db-uri = jdbc:mysql://localhost/tigasedb?user=tigase_user&password=tigase_passwd&useunicode=true&characterencoding=utf8&noaccesstoprocedurebodies=true
code:
try {             conn_valid_st.setquerytimeout(query_timeout);             st = conn.preparestatement("set character_set_client = utf8");             st.execute();             st.close();             st = conn.preparestatement("set character_set_connection = utf8");             st.execute();             st.close();             st = conn.preparestatement("set character_set_results = utf8");             st.execute();             st.close();             st = conn.preparestatement("set collation_connection = utf8_general_ci");             st.execute();             st.close();             st = conn.preparestatement("set names utf8");             st.execute();             st.close();             st = conn.preparestatement("set character set utf8");             st.execute();             st.close();         } catch (sqlexception ex) {             // ignore now, seems postgresql not support method             // call yet             if (null != st)                 st.close();              log.log(level.warning, "db server said: {0}", ex.tostring());         } what eludes me ?
edit:
create table ... engine=innodb default character set utf8 collate utf8_unicode_ci row_format=dynamic;
inserted characters: 在健身房
verification done built in command line mysql client.
edit: http://docs.oracle.com/cd/e17952_01/refman-5.0-en/connector-j-reference-charsets.html did not help
check value of system property "file.encoding". if not "utf-8", need explicitly specify "utf-8" character encoding whenever decode bytes characters. example, when call string constructor byte[], or use inputstreamreader.
problems reading/writing utf-8 data in mysql java using jdbc connector 5.1 - did not help
declared string variables in stored procedures _loc varchar(128) charset utf8 - did not help
your database table column should created proper charset , collation. can define theit while creating or altering table:
col_name {char | varchar | text} (col_length)     [character set charset_name]     [collate collation_name] here mysql link learn more it:
Comments
Post a Comment