java - char encoding doing mysql insert with callablestatement or jdbctemplate -


i having issues char encoding when performing insert mysql table. table field focused on have following properties:

collation:utf8_general_ci varchar(255)

the problem occurs chinese , foreign characters. tried using callablestatement call stored procedure not work entry appears follows:

 ????? 

i debugged , found callablestatement charencoding property has value;

cp1252 

i have not found way change this. tried setting values insert nvarchar not working. suggestion try jdbctemplate insert did not work well:

object[] params = new object[] { num, name, link,type,siteid,greetingcontroller.streamid };         int[] types = new int[] { types.nvarchar, types.nvarchar, types.nvarchar,types.integer,types.nvarchar, types.nvarchar };          recordsaffected= jdbctemplateobject.update( sql, params, types); 

and callablestatement code:

connection conn = drivermanager.getconnection(connectionurl,info);          callablestatement cstmnt = conn.preparecall("{ call   putnewpage(?,?,?,?,?,?) }");          cstmnt.setstring(1, num);         cstmnt.setstring(2, name);         cstmnt.setstring(3, link);         cstmnt.setint(4, type);         cstmnt.setstring(5, siteid);         cstmnt.setstring(6, greetingcontroller.streamid); 

this frustrating. know .net has default when working sql inserts have encoding utf-8. appreciated,

try include encoding in connection string jdbc:mysql://localhost/some_db?useunicode=yes&characterencoding=utf-8


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -