java - UTF-8 characters not stored properly to SQLite DB at runtime -


i wrote following code convert ascii data utf-8. when store data sqlite db. not store properly.

code utf-8 string in java

data = data.replaceall(":", ""); byte[] btarrbytes = hex.decodehex(data.tochararray()); string utf8data = new string(btarrbytes, "utf-8"); 

insert query sqlite in java

stringbuilder sbquery = null; stringbuilder sbvalues = null;  sbvalues.append(string.format("("                 + "\"%s\", "                  + "\"%s\", "                  + "\"%s\", "                  + "\"%s\", "                  + "\"%d\", "                  + "\"%s\", "                  + "\"%s\""                    + ")",                  sid,                  seid,                  sddatetime,                  sdevdatetime,                  objrdata.getrversionindex(),                  objrdata.getrversionname(),                 objrdata.getrversioncode()                 ));  string.format("insert \"%s\" ("  + "\"%s\", "   + "\"%s\", "   + "\"%s\", "   + "\"%s\", "   + "\"%s\", "   + "\"%s\", "   + "\"%s\""   + ") values %s",  chsqlitetbl.rversion_info.tbl_name,  chsqlitetbl.rversion_info.fld_info.id.name,  chsqlitetbl.rversion_info.fld_info.e_id.name,  chsqlitetbl.rversion_info.fld_info.d_datetime.name,  chsqlitetbl.rversion_info.fld_info.dev_datetime.name,  chsqlitetbl.rversion_info.fld_info.item_index.name,  chsqlitetbl.rversion_info.fld_info.version_name.name,  // field need save utf-8 string  chsqlitetbl.rversion_info.fld_info.version_code.name,  sbvalues.tostring()));  return sbquery.tostring(); 

query execution

connection objconnect = null; statement objstmt = null;  objconnect = objdcasqliteutility.getsqliteconnection(sdbpath); squery = objsqlitecreator.getrdatawritequery(.............) objstmt = objconnect.createstatement(); objstmt.executeupdate(squery); 

input data before conversion is

e3:83:95:e3:83:ac:e3:83:bc:e3:83:a0:e3:83:af:e3:83:bc:e3:82:af

currently utf-8 data saved follows in sqlite db

繝輔Ξ繝シ繝�繝ッ繝シ繧ッ

but should save below

フレームワーク

note in debug mode data saved properly

also, after conversion, data saved proper string in mysql database using c# insertion. data not saved proper string in sqlite db java, think problem in insert statement @ sqlite db

as said @ mysql c# data saved properly. there creating query n prefix before value following => n'{5}'

sb.appendline(                 string.format("('{0}', '{1}', '{2}', '{3}', '{4}', n'{5}', '{6}', '0', '{7}', '{8}', '{7}', '{8}'),"                 , id // 0                 , devid //1                 , sdtime // 2                 , sdevtime // 3                 , arydcarvercounter[i].index.tostring() // 4                 , arydcarvercounter[i].name // 5                 , arydcarvercounter[i].code // 6                 , supdatetime // 7                 , userid // 8                 ) 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -