JDBC Connecting to Oracle from Iran (i.e. Farsi) or any other Unknown Locale
Thanks to Nasim Kabi, here is a small code that fixes Oracle JDBC issues which prevents connecting to Oracle DB if you are in an unknown locale.
public class FixOracleFarsiLocalization { public static void fixTheBug() { try { Class clazz = Class.forName("oracle.sql.converter.CharacterSetMetaData"); Field territoryField = clazz.getDeclaredField("territory"); territoryField.setAccessible(true); Map territoryMap = (Map) territoryField.get(clazz); territoryMap.put("IR", "SAUDI ARABIA"); territoryMap.put("fa", "SAUDI ARABIA"); Field languageField = clazz.getDeclaredField("language"); languageField.setAccessible(true); Map languageMap = (Map) languageField.get(clazz); languageMap.put("fa", "ARABIC"); } catch (Exception ex) { Logger.getLogger(FixOracleFarsiLocalization.class.getName()).log(Level.SEVERE, "Exception", ex); } } }
Hi,
where we should put this function in our application
best regards
After loading JDBC driver and before connecting.
Thanks Mr.Abbaspour,
but my connection management is on Spring’s control, how can I tell Spring to run this method, after loading JDBC and before connecting?