1 Reply Latest reply: May 4, 2012 7:06 AM by Arkadiusz Knapik RSS

how to use new configuration for datasources to get utf8 encoding?

Arkadiusz Knapik Newbie

What I want to achieve is to have encoding for utf8. I use:

 

1. persistance.xml properties configuration:

     <provider>org.hibernate.ejb.HibernatePersistence</provider>

     <jta-data-source>java:/MyDS</jta-data-source>

     <properties>

            <property name="hibernate.hbm2ddl.auto" value="update"/>

            <property name="hibernate.show_sql" value="true"/>

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

            <property name="hibernate.connection.useUnicode" value="true" />

            <property name="hibernate.connection.characterEncoding" value="UTF-8" />

     </properties>

 

2. standalone.xml datasource configuration:

<subsystem xmlns="urn:jboss:domain:datasources:1.0">

<datasource jndi-name="java:/MyDS" pool-name="MyDS" enabled="true">

                    <connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>

                    <connection-property name="useUnicode">true</connection-property>

                    <connection-property name="connectionCollation">utf8_general_ci</connection-property>

                    <connection-property name="characterSetResults">utf8</connection-property>

                    <driver>mysql-connector-java-5.1.7-bin.jar</driver>

                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

                    <pool>

                        <min-pool-size>100</min-pool-size>

                        <max-pool-size>200</max-pool-size>

                    </pool>

                    <security>

                        <user-name>someRoot</user-name>

                        <password>somePass</password>

                    </security>

                    <statement>

                        <prepared-statement-cache-size>100</prepared-statement-cache-size>

                        <share-prepared-statements>true</share-prepared-statements>

                    </statement>

                </datasource>

                     <drivers>

                         <driver name="mysql-connector-java-5.1.7-bin.jar" module="com.mysql">

                             <driver-class>com.mysql.jdbc.Driver</driver-class>

                         </driver>

                     </drivers>

            </datasources>

        </subsystem>

 

And still no śćżó etc. in the base(base is utf8_general_ci).

 

What to do to get it work? Anybody help appriciated.

  • 1. Re: how to use new configuration for datasources to get utf8 encoding?
    Arkadiusz Knapik Newbie

    Instead of:

                        <connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>

                        <connection-property name="useUnicode">true</connection-property>

                        <connection-property name="connectionCollation">utf8_general_ci</connection-property>

                        <connection-property name="characterSetResults">utf8</connection-property>

    Use:

    <connection-url>jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;connectionCollation=utf8_general_ci&amp;characterSetResults=utf8&amp;characterEncoding=utf8</connection-url>

    and all works fine.