javamysqlwildflysqldatasource

problem while inserting hindi text in mysql using wildfly


I am trying to insert some hindi text in mysql table from my web page. The server I am using is wildfly. I can insert the hindi text from mysql console. But when the same query is run from my bean using datasource, it is inserted as '???????'. This led me to believe that there is some issue with mysql confinguration in wildfly. Below is the snippet of my datasource

            <datasource jta="false" jndi-name="java:/jaas/testds" pool-name="testds" enabled="true" use-ccm="false">
                <connection-url>jdbc:mysql:<HOST>:3306/DB?autoReconnect=true</connection-url>
                <driver-class>com.mysql.jdbc.Driver</driver-class>
                <connection-property name="zeroDateTimeBehavior">
                    round
                </connection-property>
                <connection-property name="jdbcCompliantTruncation">
                    false
                </connection-property>
                <driver>mysql-connector-java-5.1.23-bin.jar</driver>
                <pool>
                    <min-pool-size>10</min-pool-size>
                    <max-pool-size>100</max-pool-size>
                    <prefill>true</prefill>
                </pool>
                <security>
                    <security-domain>EncryptedPassword</security-domain>
                </security>
                <validation>
                    <validate-on-match>false</validate-on-match>
                    <background-validation>false</background-validation>
                </validation>
                <statement>
                    <share-prepared-statements>false</share-prepared-statements>
                </statement>
            </datasource>

I am thinking that I need to set some connection property to enable language support, but I am noty sure about this. Can someone pleae help me?

Thanks


Solution

  • open Your MySql table and find the column in which you want to insert Hindi text and click on change and find Collation column and select utf8_general_ci. (To prevent this type of error you should choose utf8_general_ci in Server connection collation column during database creation ).

    you can get help from a screenshot from where you have to change column