1 21 22 package org.apache.derbyTesting.functionTests.tests.i18n; 23 24 import java.util.Locale ; 25 26 import java.security.AccessController ; 27 import java.security.PrivilegedAction ; 28 import java.sql.DriverManager ; 29 import java.sql.Connection ; 30 import java.sql.SQLException ; 31 32 public class DefaultLocale { 33 34 static String savedLocale; 35 36 static { 37 savedLocale=java.util.Locale.getDefault().toString(); 38 setDefaultLocale("rr", "TT"); 39 } 40 41 42 public static void checkDefaultLocale() throws SQLException 44 { 45 String defLocale = java.util.Locale.getDefault().toString(); 46 if (!defLocale.equals("rr_TT")) 48 throw new SQLException ("wrong_locale"); 49 } 50 51 public static void checkRDefaultLocale() throws SQLException 53 { 54 String dbLocale = org.apache.derby.iapi.db.Factory.getDatabaseOfConnection().getLocale().toString(); 55 if (!savedLocale.equals(dbLocale)) 58 throw new SQLException ("wrong_locale"); 59 } 60 61 public static void checkDatabaseLocale(String Locale) throws SQLException 63 { 64 String dbLocale = org.apache.derby.iapi.db.Factory.getDatabaseOfConnection().getLocale().toString(); 65 if (!dbLocale.toUpperCase().equals(Locale.toUpperCase().trim())) 68 throw new SQLException ("wrong locale"); 69 } 70 71 public static void setDefaultLocale(final String Locale, final String Code) 73 { 74 AccessController.doPrivileged(new PrivilegedAction () { 79 public Object run() { 80 java.util.Locale.setDefault(new java.util.Locale (Locale.trim(),Code.trim())); 81 return null; } 83 }); 84 85 } 86 87 88 89 90 } 91 | Popular Tags |