Results 1 to 11 of 11
- 04-23-2011, 04:10 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
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
- 04-23-2011, 04:48 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 04-23-2011, 05:19 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
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 05:23 PM.
- 04-23-2011, 05:58 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-23-2011, 07:43 PM #5
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
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.Last edited by mcdhappy80; 04-23-2011 at 07:45 PM.
-
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.
- 04-23-2011, 09:25 PM #7
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
- 04-24-2011, 07:59 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-24-2011, 05:45 PM #9
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
Yes I'm running Windows XP Professional SP-2.
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?
I tried various methods of DatabaseMetaData but didn't find any usefull information regarding this matter.
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.Last edited by mcdhappy80; 04-24-2011 at 10:36 PM.
- 04-25-2011, 09:11 PM #10
Member
- Join Date
- Nov 2010
- Posts
- 24
- Rep Power
- 0
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.
-
Similar Threads
-
image correctly loaded, but JPanel wont display
By apchar in forum AWT / SwingReplies: 3Last Post: 04-13-2011, 03:15 AM -
Help with random letters.
By jenxin in forum New To JavaReplies: 110Last Post: 02-28-2011, 03:32 PM -
What does the letters mean?
By mustachMan in forum New To JavaReplies: 3Last Post: 02-11-2010, 09:50 PM -
Need help with counting letters
By mrdestroy in forum New To JavaReplies: 15Last Post: 10-22-2008, 01:33 PM -
need block letters??
By dc2acgsr99 in forum New To JavaReplies: 16Last Post: 01-29-2008, 08:31 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks