IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

Passage de UTF-8 à UTF-16 : problème de connexion BDD [Hibernate2]


Sujet :

Hibernate Java

  1. #1
    Membre à l'essai
    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Cantal (Auvergne)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2015
    Messages : 3
    Par défaut Passage de UTF-8 à UTF-16 : problème de connexion BDD
    Bonjour,

    Je souhaite passer ma BDD en UTF-16le pour premettre la saisie de caractères chinois.
    J'ai convertit tous mes fichiers Java dans Eclipse en UTF-16le et j'ai changé l' Interclassement pour la connexion au serveur en UTF-16le_general_ci.
    Voici mon fichier hibernate.cfg.xml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
     
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                             "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
     <session-factory >
      <!-- Database connection settings -->
      <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="connection.url">jdbc:mysql://localhost/liveview</property>
      <property name="connection.username">admin</property>
      <property name="connection.password">test</property>
      <property name="connection.useUnicode">true</property>
      <property name="connection.characterEncoding">UTF-16</property>
      <property name="connection.charSet">UTF-16</property>
      <!-- JDBC connection pool (use the built-in) -->
      <property name="connection.pool_size">1</property>
      <!-- SQL dialect -->
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
      <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>
      <!-- Disable the second-level cache -->
      <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <!-- Echo all executed SQL to stdout -->
      <property name="show_sql">false</property>
      <!-- Drop and re-create the database schema on startup -->
      <property name="hbm2ddl.auto">update</property>
      <property name="hibernate.format_sql">true</property>
      <property name="hibernate.use_sql_comments">true</property>
      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <!-- Mapping files -->
      <mapping resource="boite.hbm.xml"/>
      <mapping resource="PreReglage.hbm.xml"/>
      <mapping resource="Analyse.hbm.xml"/>
      <mapping resource="User.hbm.xml"/>
      <mapping resource="Temperature.hbm.xml"/>
      <mapping resource="TemperatureConsigne.hbm.xml"/>
     </session-factory>
    </hibernate-configuration>
    Cependant j'ai l'erreur suivante à la connexion :
    nov. 05, 2015 9:09:48 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
    INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
    nov. 05, 2015 9:09:48 AM org.hibernate.Version logVersion
    INFO: HHH000412: Hibernate Core {4.3.10.Final}
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Environment <clinit>
    INFO: HHH000206: hibernate.properties not found
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Environment buildBytecodeProvider
    INFO: HHH000021: Bytecode provider name : javassist
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration configure
    INFO: HHH000043: Configuring from resource: hibernate.cfg.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: HHH000040: Configuration resource: hibernate.cfg.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: boite.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: PreReglage.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: Analyse.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: User.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: Temperature.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: TemperatureConsigne.hbm.xml
    nov. 05, 2015 9:09:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    nov. 05, 2015 9:09:48 AM org.hibernate.cfg.Configuration doConfigure
    INFO: HHH000041: Configured SessionFactory: null
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/liveview]
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000046: Connection properties: {useUnicode=true, user=admin, password=****, characterEncoding=UTF-16, charSet=UTF-16}
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000006: Autocommit mode: false
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
    Initial SessionFactory creation failed.org.hibernate.exception.SQLGrammarException: Error calling Driver#connect
    nov. 05, 2015 9:09:48 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop

    INFO: HHH000030: Cleaning up connection pool [jdbc:mysql://localhost/liveview]
    Exception in Application start method
    Je tiens à préciser qu'en tout le projet était en UTF-8, je n'avais aucun soucis de connexion.

    Je vous remercie par avance pour votre aide.

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    1)Pourquoi l'UTF-8 ne te convenais pas? Il est tout aussi capable d'encoder le range unicode.
    2)l'encodage des fichiers java ne concerne que le compilateur, et l'utf-16 risque de faire un peux galérer ton repository SVN /Git. Bref, opération totalement inutile.
    3)l'urf-16 ne fait pas partie des encodings de connection supportés par le serveur mysql: https://dev.mysql.com/doc/connector-...-charsets.html

  3. #3
    Membre à l'essai
    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Cantal (Auvergne)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2015
    Messages : 3
    Par défaut
    En effet, tu as raison je vais repasser en UTF-8.
    Merci pour ton aide !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de connexion BDD
    Par serioos dans le forum Connexions aux bases de données
    Réponses: 2
    Dernier message: 24/04/2008, 09h56
  2. Réponses: 4
    Dernier message: 06/03/2008, 13h08
  3. [RAD 2007][.Net2][MSSQL] Problème de connexion bdd
    Par Peck777 dans le forum Delphi .NET
    Réponses: 4
    Dernier message: 20/12/2007, 11h39
  4. [MySQL] Problème de connexion à bdd chez free
    Par clad523 dans le forum PHP & Base de données
    Réponses: 5
    Dernier message: 23/04/2006, 14h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo