1 21 22 package org.apache.derby.client.am; 23 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.security.AccessController ; 27 import java.security.PrivilegedExceptionAction ; 28 29 import org.apache.derby.iapi.services.info.ProductGenusNames; 30 import org.apache.derby.iapi.services.info.ProductVersionHolder; 31 import org.apache.derby.shared.common.reference.SQLState; 32 import org.apache.derby.iapi.services.info.JVMInfo; 33 34 public class Configuration { 35 36 37 public static int traceFileSuffixIndex__ = 0; 38 39 public static int traceLevel__ = org.apache.derby.jdbc.ClientBaseDataSource.TRACE_ALL; 40 41 public static String traceFile__ = null; 42 43 public static String traceDirectory__ = null; 44 45 public static boolean traceFileAppend__ = false; 46 public static String jreLevel = "1.3.0"; public static int jreLevelMajor = 1; 48 public static int jreLevelMinor = 3; 49 50 private Configuration() { 51 } 52 53 public static boolean traceSuspended__; 54 55 public static boolean[] enableConnectivityToTargetServer__; 56 public static boolean jvmSupportsMicrosClock__ = false; 57 58 60 public static ProductVersionHolder dncProductVersionHolder__; 61 62 public static ProductVersionHolder getProductVersionHolder() { 63 return dncProductVersionHolder__; 64 } 65 66 67 public final static String dncDriverName = "Apache Derby Network Client JDBC Driver"; 69 70 71 public final static byte[] dncPackageConsistencyToken = 75 {0x53, 0x59, 0x53, 0x4c, 0x56, 0x4c, 0x30, 0x31}; 76 77 public static String dncPackageVersion = null; 80 81 public final static boolean jdbcCompliant = true; 83 84 public final static String [] dncCompatibleJREVersions = new String []{"1.3", "1.4"}; 86 87 89 public final static String jdbcDerbyNETProtocol = "jdbc:derby://"; 91 92 96 98 public final static boolean enableNetConnectionPooling = true; 99 100 final static boolean rangeCheckCrossConverters = true; 101 102 final static int bugCheckLevel = 0xff; 104 105 107 public final static int defaultIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED; 109 110 112 public static final int defaultFetchSize = 64; 113 114 public static final String cursorAttribute_SensitiveStatic = "SENSITIVE STATIC SCROLL "; 116 public static final String cursorAttribute_SensitiveStaticRowset = cursorAttribute_SensitiveStatic; 117 public static final String cursorAttribute_SensitiveDynamic = "SENSITIVE DYNAMIC SCROLL "; 118 public static final String cursorAttribute_SensitiveDynamicRowset = "SENSITIVE DYNAMIC SCROLL WITH ROWSET POSITIONING "; 119 public static final String cursorAttribute_Insensitive = "INSENSITIVE SCROLL "; 120 public static final String cursorAttribute_InsensitiveRowset = cursorAttribute_Insensitive; 121 122 127 public static final String cursorAttribute_ForUpdate = "FOR UPDATE "; 128 public static final String cursorAttribute_ForReadOnly = "FOR READ ONLY "; 129 130 public static final String cursorAttribute_WithHold = "WITH HOLD "; 131 132 134 private static final String packageNameForDNC = "org.apache.derby.client"; 135 136 public static SqlException exceptionsOnLoadResources = null; 138 static { 139 try { 140 loadProductVersionHolder(); 141 } catch (SqlException e) { 142 exceptionsOnLoadResources = e; 143 } 144 try { 145 jreLevel = System.getProperty("java.version"); 146 } catch (SecurityException e) { 147 } java.util.StringTokenizer st = new java.util.StringTokenizer (jreLevel, "."); 149 int jreState = 0; 150 while (st.hasMoreTokens()) { 151 int i; 152 try { 153 i = java.lang.Integer.parseInt(st.nextToken()); } catch (NumberFormatException e) { 155 i = 0; 156 } 157 switch (jreState++) { 158 case 0: 159 jreLevelMajor = i; break; 161 case 1: 162 jreLevelMinor = i; break; 164 default: 165 break; } 167 } 168 } 169 170 173 private static void loadProductVersionHolder() throws SqlException { 174 try { 175 dncProductVersionHolder__ = buildProductVersionHolder(); 176 } catch (java.security.PrivilegedActionException e) { 177 throw new SqlException(null, 178 new ClientMessageId (SQLState.ERROR_PRIVILEGED_ACTION), 179 e.getException()); 180 } catch (java.io.IOException ioe) { 181 throw SqlException.javaException(null, ioe); 182 } 183 } 184 185 186 private static ProductVersionHolder buildProductVersionHolder() throws 188 java.security.PrivilegedActionException , IOException { 189 ProductVersionHolder myPVH = null; 190 myPVH = (ProductVersionHolder) 191 AccessController.doPrivileged(new PrivilegedExceptionAction () { 192 193 public Object run() throws IOException { 194 InputStream versionStream = getClass().getResourceAsStream(ProductGenusNames.DNC_INFO); 195 196 return ProductVersionHolder.getProductVersionHolderFromMyEnv(versionStream); 197 } 198 }); 199 200 return myPVH; 201 } 202 203 206 207 public static boolean supportsJDBC40() { 208 if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) { 209 return true; 210 } 211 return false; 212 } 213 214 215 216 } 217 | Popular Tags |