0

I am working on a project that i need to create a connection with an MS access database. The problem is that when i try to retrieve a valuefrom a field written in Greek , it appears every letter as questionmark . Does anyone have any idea how to solve it ?

Below is a part of my code where the problem appears

String KTA1 = KA4prwta.getText() + KA3teleutaia.getText();//KTA
        String selectSQL = "SELECT * FROM [" + tablename + " ] WHERE KTA ='" + KTA1 + "'";
        try {
            PreparedStatement preparedStatement = conn.prepareStatement(selectSQL);

            ResultSet rs = preparedStatement.executeQuery();
            while (rs.next()) {
                ep = rs.getString("EPON");
                on = rs.getString("ONOM");
            }
            Epwnumotf.setText(ep);
            Onomatf.setText(on);
        } catch (SQLException ex) {
            Logger.getLogger(DBinsert.class.getName()).log(Level.SEVERE, null, ex);
        }
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
JohnLaz
  • 1
  • 1

1 Answers1

0

The issue you have sounds like it's a language encoding issue but without more information, it's hard to suggest a solution.

Where are you 'seeing' these question marks? Wherever it is, you should try using a multi-byte encoded display language and see if that resolves your issue.

E.g. if you're displaying on a website, make sure you're displaying UTF8.

  • I think you mean `character encoding`, Java doesn't know how to translate languages, but it would be cool/amazing if it could. ;) – Peter Lawrey Jul 09 '14 at 08:32
  • Sorry, yes - I meant character encoding - my brain is not quite full speed yet this morning. Not sure what you mean about translation though. – WombatCombat Jul 09 '14 at 08:35
  • I mean like this https://translate.google.com/ but using a Java API. – Peter Lawrey Jul 09 '14 at 08:38
  • i see questionmarks as i set value from DB field to textfields of a GUI.The same issue appears in the ouput console though.I guess is an encoding problem as i retrieve value fields from Database . English charactes appear perfectly. – JohnLaz Jul 09 '14 at 08:39
  • You're probably using a single byte character set. Try a double byte character set and see if your problem is still happening. – WombatCombat Jul 10 '14 at 09:35