Back Forum Reply New

unable to insert arabic data

Hi All,

Am trying to do small application with java , spring , hibernate , the problem is that am not able to insert arabic data inspite of my specifications in the spring configuration file
to use utf-8 as well the database charcterset is utf-8 here is part of the configuration file

Code:
lt;bean id=quot;dataSourcequot; class=quot;org..jdbc.datasource.DriverManagerDataSourcequot;gt;   lt;property name=quot;driverClassNamequot; value=quot;com.mysql.jdbc.Driverquot; /gt;   lt;property name=quot;uclquot; value=quot;jdbc:mysql--localhost:3306/generalquot; /gt;   lt;property name=quot;usernamequot; value=quot;testquot; /gt;   lt;property name=quot;passwordquot; value=quot;testquot; /gt;   
lt;/beangt;lt;bean id=quot;sessionFactoryquot;        class=quot;org..orm.hibernate3.LocalSessionFactoryBeanquot;gt;     lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot; /gt;     lt;property name=quot;mappingResourcesquot;gt;        lt;listgt;lt;valuegt;com/account/Account.hbm.xmllt;/valuegt;lt;valuegt;com/account/ShortCode.hbm.xmllt;/valuegt;        lt;/listgt;     lt;/propertygt;     lt;property name=quot;hibernatePropertiesquot;gt;        lt;propsgt;lt;prop key=quot;hibernate.dialectquot;gt;org.hibernate.dialect.MySQLDialectlt;/propgt;lt;prop key=quot;hibernate.hbm2ddl.autoquot;gt;updatelt;/propgt; lt;!-- lt;prop key=quot;hibernate.show_sqlquot;gt;truelt;/propgt; --gt;lt;prop key=quot;hibernate.connection.useUnicodequot;gt;truelt;/propgt;lt;prop key=quot;hibernate.connection.characterEncodingquot;gt;UTF-8lt;/propgt; lt;prop key=quot;hibernate.connection.charSetquot;gt;UTF-8lt;/propgt;         lt;/propsgt;     lt;/propertygt;  lt;/beangt;

by the way when i try to insert arabic data , the data will be inserted as question marks in the table of the database.

Hi All,

Thanks alot , i have fixed the issue ,

i have added the following into the ucl

?useUnicode=trueamp;amp;characterEncoding=utf-8so my code becomes as the following Code:
lt;bean id=quot;dataSourcequot; class=quot;org..jdbc.datasource.DriverManagerDataSourcequot;gt;   lt;property name=quot;driverClassNamequot; value=quot;com.mysql.jdbc.Driverquot; /gt;   lt;property name=quot;uclquot; value=quot;jdbc:mysql--localhost:3306/general?useUnicode=trueamp;amp;characterEncoding=utf-8quot; /gt;   lt;property name=quot;usernamequot; value=quot;testquot; /gt;   lt;property name=quot;passwordquot; value=quot;testquot; /gt;   
lt;/beangt;lt;bean id=quot;sessionFactoryquot;        class=quot;org..orm.hibernate3.LocalSessionFactoryBeanquot;gt;     lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot; /gt;     lt;property name=quot;mappingResourcesquot;gt;        lt;listgt;lt;valuegt;com/account/Account.hbm.xmllt;/valuegt;lt;valuegt;com/account/ShortCode.hbm.xmllt;/valuegt;        lt;/listgt;     lt;/propertygt;     lt;property name=quot;hibernatePropertiesquot;gt;        lt;propsgt;lt;prop key=quot;hibernate.dialectquot;gt;org.hibernate.dialect.MySQLDialectlt;/propgt;lt;prop key=quot;hibernate.hbm2ddl.autoquot;gt;updatelt;/propgt; lt;!-- lt;prop key=quot;hibernate.show_sqlquot;gt;truelt;/propgt; --gt;
        lt;/propsgt;     lt;/propertygt;  lt;/beangt;
it is working perfect now



Why don't you add the encoding filter in your web.xml ?Code:   lt;filtergt;       lt;filter-namegt;CharacterEncodinglt;/filter-namegt;       lt;filter-classgt;
org..web.filter.CharacterEncodingFilter       lt;/filter-classgt;       lt;init-paramgt;lt;param-namegt;encodinglt;/param-namegt;lt;param-valuegt;UTF-8lt;/param-valuegt;       lt;/init-paramgt;       lt;init-paramgt;lt;param-namegt;forceEncodinglt;/param-namegt;lt;param-valuegt;truelt;/param-valuegt;       lt;/init-paramgt;   lt;/filtergt;
BYE
¥
Back Forum Reply New