This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trouble with string

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm developing a home app (swing standalone app and database) in my laptop (for a long time...)
my environment:
winXP home SP2
eclipse 3.1 with all updates
using visual editor for eclipse
hibernate 2.1.7
MySQL 4.1.10a-nt
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

my app is nearly finished, so i made a jar (troubles with this will follow) and tried it in my pc, wich is winXP pro SP2, and then installed the same MySQL; the jre is the very same

at a certain point my app has a button that populates some fields based in a hql query:

private final String QUERY_CONTRATO_T =

"from ContratoTecnica c "

+ "WHERE nomeActoMedico = ? "

+ "and tipoContrato = ? "

+ "order by nomeActoMedico asc, data desc";

both nomeActoMedico and tipoContrato are strings.
What happens is extraordinary: in my laptop everything goes fine, but in my pc the query doesnt return as expected, when strings include some characters, like:
"Conven��o", "Domic�lio" and so on

I dont have the smallest idea why this is happening

Can someone please give me any hint?

TiA
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a character set issue. If this were Oracle I'd say you needed to use NVARCHAR and configure the database to allow 16-bit characters. Not sure how MySql deals with such issues, don't use it that often.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to "JDBC".
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case its a MySQL prob, here's what i get from mysql command line:
mysql> select tipocontrato from contrato;
+--------------+
| tipocontrato |
+--------------+
| Conven��o |
| Conven��o |
| Conven��o |
| Conven��o |
| Conven��o |
| Conven��o |
| Conven��o |
| Particular |
| Particular |
+--------------+
9 rows in set (0.00 sec)

but, if i use mysql query browser, i get:
'Conven��o'
'Conven��o'
'Conven��o'
'Conven��o'
'Conven��o'
'Conven��o'
'Conven��o'
'Particular'
'Particular'


EDIT:
i also found out that MySQL charset is utf8 and collation is utf8_general_ci
[ March 19, 2006: Message edited by: miguel lisboa ]
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just replicated as before, but this time using hsqldb, but with the very same (sad) results
dont know what to do
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for some reason, inside my MySQL install, in db.opt file, i found this:
default-character-set=latin1
default-collation=latin1_swedish_ci

as i'm in Portugal, i tried:
default-character-set=latin1
#default-collation=latin1_swedish_ci
default-collation=latin1_general_cs

and now all works fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic