• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Issue with special characters

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
iam creating a java class to read values from excel and insert into DB. Iam using POI package. In excel i have one column which has values like this ≤ 7⅜ x 9¼“ or 260 x 195mm. After reading the values from the cell using POI it is inserted into database as ? 7? x 9?? or 260 x 195mm. First i thought that it is something to do with POI package and was searching for a solution. But after searching i found that it is not issue with POI. It is something to do with java. To confirm this i just assigned the value to a string (hardcoded) and when i did system.out.println it gives output as below. Special characters are replaced by ?.



but the output is: ? 7? x 9?? or 260 x 195mm

What should i do for this?

Thanks.
 
Marshal
Posts: 80294
434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start by trying the display on a Java component: JOptionPane.showMessagedialog(null, "value:"+printVal);
The Windows® terminal is notorious for displaying only a restricted range of characters. I hve had command lines where £ appeared as ú!
 
Thanuja Vishwanath
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Start by trying the display on a Java component: JOptionPane.showMessagedialog(null, "value:"+printVal);
The Windows® terminal is notorious for displaying only a restricted range of characters. I hve had command lines where £ appeared as ú!



Even in mysql database it is getting inserted like this. Only because of this i added print statement to check.

Thanks.
 
Campbell Ritchie
Marshal
Posts: 80294
434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what happened when you tried the JOptionPane?
What is the encoding you have set on your database?
 
Thanuja Vishwanath
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:And what happened when you tried the JOptionPane?
What is the encoding you have set on your database?



Campbell as you said it is printing properly in JOptionPane. I checked my database encoding which was latin. I changed it to utf8 and also changed the table properties to utf8. Again i executed my program and it inserts with question mark in the db. But when i tried to store directly in table using insert query it is properly inserted. From this i feel i fixed the db issue by changing latin to utf8. I guess problem is the value passed from java. iam bit confused with this and not sure why it is printing in jOptionPane properly but not getting inserted in db properly.

Please advise should i do anything else in java part?

Thanks.
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have not provided much information about how it is stored in the DB.
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic