Results 1 to 11 of 11
  1. #1
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Question Some letters don't display correctly

    I've build a Java application on top of Access 2007 database.
    Almost all text fields in the database contain some letters that are from the Utf-8 character encoding system. When I load the database data int the Java list all the letters form Utf-8 display as "?" character.
    So can someone tell me what is the real problem here, why does Java displays those letters the way it displays them and can I and how solve this problem?
    Thank You

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by mcdhappy80 View Post
    I've build a Java application on top of Access 2007 database.
    Almost all text fields in the database contain some letters that are from the Utf-8 character encoding system. When I load the database data int the Java list all the letters form Utf-8 display as "?" character.
    So can someone tell me what is the real problem here, why does Java displays those letters the way it displays them and can I and how solve this problem?
    Thank You
    Can you show us how you are reading a single column from the database? Also, are you using a Font that actually can display those character glyphs?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Question

    Quote Originally Posted by JosAH View Post
    Can you show us how you are reading a single column from the database? Also, are you using a Font that actually can display those character glyphs?

    kind regards,

    Jos
    I'm not sure I understood the font question part well. I don't think I am using any special fonts. The problematic letters are "Ž, Š, Č, Ć,".
    If I understood Your demand correctly here is the piece of code, I've bolded the value assignment part:

    Java Code:
    public static ListaCekanja dajListuCekanja(){
    
            ListaCekanja lc = new ListaCekanja();
    
            String SQL = "SELECT txtMBDeteta, txtPrezime, txtSrednjeIme, " +
                    "txtIme, dteDatumRodjenja " +
                    "FROM tblDete0 " +
                    "ORDER BY txtPrezime, txtSrednjeIme, txtIme ASC";
            
            ResultSet rs1 = null;
            rs1 = GenericDataAccess.getResultSet(SQL,"DULaneDB\\DULaneDB.accdb");
            
            try {
                while (rs1.next()) {
    
                    //Promenljive deteta
                    String jmbg = null;
                    String prezime = null;
                    String srednjeIme = null;
                    String ime = null;
                    String datumRodjenja = null;
    
                    [B]jmbg = rs1.getString("txtMBDeteta");
                    prezime = rs1.getString("txtPrezime");
                    srednjeIme =rs1.getString("txtSrednjeIme");
                    ime =  rs1.getString("txtIme");
                    datumRodjenja = String.valueOf(rs1.getDate("dteDatumRodjenja"));[/B]
    
                    // *** Test Encodinga ***
                    
    
                    Dete a = new Dete();
                    a.setTxtJMBG(jmbg);
                    a.setTxtPrezime(prezime);
                    a.setTxtSIme(srednjeIme);
                    a.setTxtIme(ime);
                    a.setDteDatumRodjenja(datumRodjenja);
    
                    lc.dodajDete(a);
    
                }
               
            } catch (SQLException e) {
                System.out.println("SQL Exception: " + e.toString());
            } finally {
                GenericDataAccess.zatvoriKonekciju();
                System.out.println("Konekcija zatvorena");
            }
            return lc;
        }
    Last edited by mcdhappy80; 04-23-2011 at 06:23 PM.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default

    Can you properly list the content of that table without Java, i.e. are you sure the content is properly stored in your database?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Arrow

    Quote Originally Posted by JosAH View Post
    Can you properly list the content of that table without Java, i.e. are you sure the content is properly stored in your database?

    kind regards,

    Jos
    Yes, I have an Access 2007 application that is used for entering data and it displays data correctly (as You can see on picture in attachment).
    I wanted to go further with this app (make it more OO), it works perfect in Access.
    Is this maybe some Java - Access issue, because I've noticed in every examples across internet, people recommend MySQL as a database when working with Java (or maybe that was my impression)?

    Thank You.
    Attached Thumbnails Attached Thumbnails Some letters don't display correctly-access-app.jpg  
    Last edited by mcdhappy80; 04-23-2011 at 08:45 PM.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I think that it's an issue with the Java console not allowing for the correct charset. I suggest you print the output to a file using an OutputStreamWriter with the appropriate charset or else to display the data, use a Swing GUI.

  7. #7
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Question

    Quote Originally Posted by Fubarable View Post
    I think that it's an issue with the Java console not allowing for the correct charset. I suggest you print the output to a file using an OutputStreamWriter with the appropriate charset or else to display the data, use a Swing GUI.
    Can You give code examples of what You are saying, because I tried finding it online, found bunch of stuff, but not sure which one and how to use.

    I am displaying the data using list and table in Java and the incorrect display is there also.

    Thank You
    Attached Thumbnails Attached Thumbnails Some letters don't display correctly-javalist.jpg   Some letters don't display correctly-javatable.jpg  

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by mcdhappy80 View Post
    Can You give code examples of what You are saying, because I tried finding it online, found bunch of stuff, but not sure which one and how to use.

    I am displaying the data using list and table in Java and the incorrect display is there also.

    Thank You
    I guess your running this on a MS Windows box; can you change the font of the display-lists etc. to "Arial Unicode MS"? That font is certainly able to display those letters. Otherwise maybe the DatabaseMetaData can be of help (you can get that object from a Connection); I'm not sure about this, I don't have the documentation handy and I'm too lazy to go into the house now ;-)
    What is the definition of your table? Are those text columns actually unicode character strings?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Question

    Quote Originally Posted by JosAH View Post
    I guess your running this on a MS Windows box
    Yes I'm running Windows XP Professional SP-2.

    Quote Originally Posted by JosAH View Post

    ; can you change the font of the display-lists etc. to "Arial Unicode MS"? That font is certainly able to display those letters.
    I'm not quite sure I understand You here. Change the font where? In Windows Settings, or in the IDE (NetBeants 6.8) I'm using, or in the code itself?

    Quote Originally Posted by JosAH View Post
    Otherwise maybe the DatabaseMetaData can be of help (you can get that object from a Connection); I'm not sure about this, I don't have the documentation handy and I'm too lazy to go into the house now ;-)
    I tried various methods of DatabaseMetaData but didn't find any usefull information regarding this matter.

    Quote Originally Posted by JosAH View Post
    What is the definition of your table? Are those text columns actually unicode character strings?
    How do I see table definition? What do You mean by "Table Definition"?
    I attached a picture if that was what You meant (about Unicode character strings)? If I guessed wrong with the picture how do I check this?
    I tried switching the option on the picture but nothing changes.

    Thank You

    P.S. - Just for purpose of eliminating the potential causes to this I tried connecting to SQL Server database (via ODBC) just to see if the problem will persist. Even with SQL Server database the letters are displaying the same, so I must believe this has something to do with Java itself and not with the database.
    Attached Thumbnails Attached Thumbnails Some letters don't display correctly-unicodecompression.jpg  
    Last edited by mcdhappy80; 04-24-2011 at 11:36 PM.

  10. #10
    mcdhappy80 is offline Member
    Join Date
    Nov 2010
    Posts
    24
    Rep Power
    0

    Lightbulb Solved

    Apparently this problem has no solution for now Bug ID: 6345277 JDBC-ODBC Bridge still does not support Unicode UTF-16.
    Thank You all.

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. image correctly loaded, but JPanel wont display
    By apchar in forum AWT / Swing
    Replies: 3
    Last Post: 04-13-2011, 04:15 AM
  2. Help with random letters.
    By jenxin in forum New To Java
    Replies: 110
    Last Post: 02-28-2011, 04:32 PM
  3. What does the letters mean?
    By mustachMan in forum New To Java
    Replies: 3
    Last Post: 02-11-2010, 10:50 PM
  4. Need help with counting letters
    By mrdestroy in forum New To Java
    Replies: 15
    Last Post: 10-22-2008, 02:33 PM
  5. need block letters??
    By dc2acgsr99 in forum New To Java
    Replies: 16
    Last Post: 01-29-2008, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •