Mysql conector et "é" "è"

toutphp Messages postés 107 Date d'inscription lundi 24 mai 2004 Statut Membre Dernière intervention 5 mai 2010 - 1 mars 2005 à 09:25
cs_neodante Messages postés 2835 Date d'inscription lundi 11 août 2003 Statut Modérateur Dernière intervention 16 décembre 2006 - 2 mars 2005 à 00:31
Bonjour tous,



je souhaiterai afficher les caractères accentués d'un requete SELECT via MySQL Jconnector.

Comment dois-je faire SVP ? Pour l'instant j'ai ceci :



Etrang?re au lieu de Etrangère.



Merci à vous

6 réponses

cs_neodante Messages postés 2835 Date d'inscription lundi 11 août 2003 Statut Modérateur Dernière intervention 16 décembre 2006 11
1 mars 2005 à 13:10
Salut



Tu fais ça en mode console non ???


Construis ton InputStreamReader avec le constructeur suivant :

InputStreamReader(InputStream in,
                  String charsetName)



En tant que charset tu peux utiliser :

<tt>US-ASCII</tt>,
Seven-bit ASCII, a.k.a. <tt>ISO646-US</tt>,
a.k.a. the Basic Latin block of the Unicode character set,
----
<tt>ISO-8859-1 </tt>,
ISO Latin Alphabet No. 1, a.k.a. <tt>ISO-LATIN-1</tt>,
----
<tt>UTF-8</tt>,
Eight-bit UCS Transformation Format,
----
<tt>UTF-16BE</tt>,
Sixteen-bit UCS Transformation Format,
big-endian byte order,
----
<tt>UTF-16LE</tt>,
Sixteen-bit UCS Transformation Format,
little-endian byte order,
----
<tt>UTF-16</tt>,
Sixteen-bit UCS Transformation Format,
byte order identified by an optional byte-order mark

Voilà !



@+
0
cs_neodante Messages postés 2835 Date d'inscription lundi 11 août 2003 Statut Modérateur Dernière intervention 16 décembre 2006 11
1 mars 2005 à 13:13
Salut



Fais donc new InputStreamReader(System.in, "ISO-8859-1"); Combine avec un BufferedReader pour avoir accés à readLine() ...



@+
0
toutphp Messages postés 107 Date d'inscription lundi 24 mai 2004 Statut Membre Dernière intervention 5 mai 2010
1 mars 2005 à 14:53
Comment je fais car je fait une connexion, puis un statement.
Où dois-je le déclarer et l'utiliser.

Sinon j'ai une interface dans laquelle j'affiche un liste avec les differents elements de la requete select
0
cs_neodante Messages postés 2835 Date d'inscription lundi 11 août 2003 Statut Modérateur Dernière intervention 16 décembre 2006 11
1 mars 2005 à 16:00
Salut



Sinon fait un new String("Ma string récup de JDBC", "ISO-8859-1");
C'est un peu à l'arrache mais bon par défaut c'est l'encodage unicode
... le mieux est donc de mettre tes tables en encodage unicode ....



@+
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
toutphp Messages postés 107 Date d'inscription lundi 24 mai 2004 Statut Membre Dernière intervention 5 mai 2010
1 mars 2005 à 19:07
Apparement le constructeur de String que tu donne n'existe pas.

Par contre j'ai ceci :




String tmp = (String)categorieList.getSelectedItem();

int id_categorie,id_format,id_auteur,id_editeur;

String requete="SELECT id_categorie FROM categorie WHERE libelle =""+new String(tmp.getBytes(),"ISO-8859-1")+""";

System.out.println(requete);





Je suis donc obliger d'attraper une UnsupportedEncodingException.



Mais ça ne marche pas, quand j'affiche la requete dans un textfield, il y a toujours ces "?"



Pour ce qui est de l'encodage Unicode de ma base, je ne vois pas trop comment faire.



Merci
0
cs_neodante Messages postés 2835 Date d'inscription lundi 11 août 2003 Statut Modérateur Dernière intervention 16 décembre 2006 11
2 mars 2005 à 00:31
Salut



Oups :


new String("Ma string récup de JDBC".getBytes(), "ISO-8859-1")



Regarde la javadoc si tu as un doute sur un constructeur :

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html



@+
0
Rejoignez-nous