Bonjour,
J'ai quelques soucis pour afficher correctement côté Java les données textuelles grecques d'une colonne CLOB d'une base Oracle :
Le CHARACTER_SET de la base :Oracle DATABASE 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS FOR Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Le script de la table :
Code : Sélectionner tout - Visualiser dans une fenêtre à part NLS_CHARACTERSET AL32UTF8
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 CREATE TABLE MY_MARKUP_TABLE ( QUERY_ID NUMBER, DOCUMENT CLOB )
Le code pour récupérer et afficher le contenu :
Code java : 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
39
40 try { conn = getConnection(); Statement stmt = conn.createStatement(); // Execute the function and get the return object from the call ResultSet rs = stmt.executeQuery("select DOCUMENT from MY_MARKUP_TABLE"); rs.next(); Clob var = rs.getClob("DOCUMENT"); Reader in = var.getCharacterStream(); StringBuffer buf = new StringBuffer(); try { for (int c = in.read(); c != -1; c = in.read()) { buf.append((char) c); } } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (Exception e) { e.printStackTrace(); } } System.out.println(buf.toString()); } catch (SQLException e) { e.printStackTrace(); } finally { closeConnection(conn); }
Avec SQL Developper, les caractères sont correctement affichés (cf. pièce jointe).
Et ma console m'affiche via le System.out.println(buf.toString()); :
Code hml : 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 <html><body><p/> <br /><font face="Times New Roman" size="3">EL<div align="center"></font> <p><font face="Times New Roman" size="3"><b>SANCO/3175/2007 Rev.1 (POOL/E3/2007/3175/3175R1-EN.doc)</b></font> <p><font face="Times New Roman" size="3"> </font> <br style="page-break-before:always" /> </div> <table width="631" border="1"><tr valign="top"><td width="120"><font face="Arial" size="3"><br /></font> </td> <td width="510"><font face="Arial" size="3">???????? ??? ?????????? ??????????</font> </td> </tr> </table> <font face="Times New Roman" size="3">B????????,</font> <p><font face="Times New Roman" size="3">C(2007) ??????<div align="center"></font> <p><font face="Times New Roman" size="3">??????</font> <p><font face="Times New Roman" size="3"><b>??????? ??? ?????????</b></font> <p><font face="Times New Roman" size="3"><b>???</b></font> <p><font face="Times New Roman" size="3"><b>??? ??? ??????????? ??? ??????? 2002/72/?? ??????? ?? ?? ???????? ????? ??? ??????????? ??? ???????????? ?? ?????? ?? ????? ?? ??????? </b></font> <p><font face="Times New Roman" size="3">(???????? ??? ?. ?. ?????????)</font> <p><font face="Times New Roman" size="5"><u><b> </b></u></font> ... ...
J'imagine très bien qu'il y a un souci d'encoding, mais là je suis un peu perdu.
La version de Java est 1.4.2_13.
Merci d'avance pour votre aide.
Partager