private void initializeFromClassPath(String classpath) throws StandardException { final String[][] elements = IdUtil.parseDbClassPath(classpath); final int jarCount = elements.length; jarList = new JarLoader[jarCount]; if (jarCount != 0) { // Creating class loaders is a restricted operation // so we need to use a privileged block. AccessController.doPrivileged( new java.security.PrivilegedAction() { public Object run() { for (int i = 0; i < jarCount; i++) { jarList[i] = new JarLoader(UpdateLoader.this, elements[i], vs); } return null; } }); } if (vs != null) { vs.println(MessageService.getTextMessage(MessageId.CM_CLASS_LOADER_START, classpath)); } thisClasspath = classpath; initDone = false; }
/** * Delete a row from our index. This assumes our index ScanController is positioned before the row * by setScan if we own the SC, otherwise it is positioned on the row by the underlying index * scan. * * <p>This verifies the row exists and is unique. * * @exception StandardException Thrown on error */ private void doDelete() throws StandardException { if (ownIndexSC) { if (!indexSC.next()) { // This means that the entry for the index does not exist, this // is a serious problem with the index. Past fixed problems // like track 3703 can leave db's in the field with this problem // even though the bug in the code which caused it has long // since been fixed. Then the problem can surface months later // when the customer attempts to upgrade. By "ignoring" the // missing row here the problem is automatically "fixed" and // since the code is trying to delete the row anyway it doesn't // seem like such a bad idea. It also then gives a tool to // support to be able to fix some system catalog problems where // they can delete the base rows by dropping the system objects // like stored statements. /* dem 2013/04/10 - temporarily comment this out while we are getting snapshot isolation DDL support in place if (SanityManager.DEBUG) SanityManager.THROWASSERT( "Index row "+RowUtil.toString(ourIndexRow)+ " not found in conglomerateid " + indexCID + "Current scan = " + indexSC); */ Object[] args = new Object[2]; args[0] = ourIndexRow.getRowArray()[ourIndexRow.getRowArray().length - 1]; args[1] = new Long(indexCID); Monitor.getStream() .println( MessageService.getCompleteMessage( SQLState.LANG_IGNORE_MISSING_INDEX_ROW_DURING_DELETE, args)); // just return indicating the row has been deleted. return; } } indexSC.delete(); }
/** * Load the class from the class path. Called by JarLoader when it has a request to load a class * to fulfill the sematics of db.database.classpath. * * <p>Enforces two restrictions: * * <UL> * <LI>Do not allow classes in certain name spaces to be loaded from installed jars, see * RESTRICTED_PACKAGES for the list. * <LI>Referencing Derby's internal classes (those outside the public api) from installed is * disallowed. This is to stop user defined routines bypassing security or taking advantage * of security holes in Derby. E.g. allowing a routine to call a public method in db would * allow such routines to call public static methods for system procedures without having * been granted permission on them, such as setting database properties. * </UL> * * @exception ClassNotFoundException Class can not be found or the installed jar is restricted * from loading it. */ Class loadClass(String className, boolean resolve) throws ClassNotFoundException { JarLoader jl = null; boolean unlockLoader = false; try { unlockLoader = lockClassLoader(ShExQual.SH); synchronized (this) { if (needReload) { reload(); } Class clazz = checkLoaded(className, resolve); if (clazz != null) return clazz; // Refuse to load classes from restricted name spaces // That is classes in those name spaces can be not // loaded from installed jar files. for (int i = 0; i < RESTRICTED_PACKAGES.length; i++) { if (className.startsWith(RESTRICTED_PACKAGES[i])) throw new ClassNotFoundException(className); } String jvmClassName = className.replace('.', '/').concat(".class"); if (!initDone) initLoaders(); for (int i = 0; i < jarList.length; i++) { jl = jarList[i]; Class c = jl.loadClassData(className, jvmClassName, resolve); if (c != null) { if (vs != null) vs.println( MessageService.getTextMessage( MessageId.CM_CLASS_LOAD, className, jl.getJarName())); return c; } } // Ok we are missing the class, we will try to reload once and Find it... reload(); initDone = false; initLoaders(); for (int i = 0; i < jarList.length; i++) { jl = jarList[i]; Class c = jl.loadClassData(className, jvmClassName, resolve); if (c != null) { if (vs != null) vs.println( MessageService.getTextMessage( MessageId.CM_CLASS_LOAD, className, jl.getJarName())); return c; } } } return null; } catch (StandardException se) { throw new ClassNotFoundException( MessageService.getTextMessage( MessageId.CM_CLASS_LOAD_EXCEPTION, className, jl == null ? null : jl.getJarName(), se)); } finally { if (unlockLoader) { lf.unlock(compat, this, classLoaderLock, ShExQual.SH); } } }
/** Construct an SQLException whose message and severity are derived from the message id. */ public final SQLException getSQLException( String messageId, SQLException next, Throwable cause, Object[] args) { String message = MessageService.getCompleteMessage(messageId, args); int severity = StandardException.getSeverityFromIdentifier(messageId); return getSQLException(message, messageId, next, severity, cause, args); }