⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genericpreparedstatement.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			 * executeUpdate() not allowed on statements			 * that return a ResultSet.			 * We need to do the test here so that any			 * exeception will rollback to the statement			 * savepoint.			 */			if ( (! resultSet.returnsRows()) && executeQuery)			{				throw StandardException.newException(SQLState.LANG_INVALID_CALL_TO_EXECUTE_QUERY);			}			if ( resultSet.returnsRows() && executeUpdate)			{				throw StandardException.newException(SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE);			}			return resultSet;					}	}	public ResultDescription	getResultDescription()	{		return resultDesc;	}	public DataTypeDescriptor[]	getParameterTypes()	{		return paramTypeDescriptors;	}	public String getSource() {		return (sourceTxt != null) ?			sourceTxt : 			(statement == null) ? 				"null" : 				statement.getSource();	}	public void setSource(String text)	{		sourceTxt = text;	}	public final void setSPSName(String name) {		spsName = name;	}	public String getSPSName() {		return spsName;	}	/**	 * Get the total compile time for the associated query in milliseconds.	 * Compile time can be divided into parse, bind, optimize and generate times.	 * 	 * @return long		The total compile time for the associated query in milliseconds.	 */	public long getCompileTimeInMillis()	{		return compileTime;	}	/**	 * Get the parse time for the associated query in milliseconds.	 * 	 * @return long		The parse time for the associated query in milliseconds.	 */	public long getParseTimeInMillis()	{		return parseTime;	}	/**	 * Get the bind time for the associated query in milliseconds.	 * 	 * @return long		The bind time for the associated query in milliseconds.	 */	public long getBindTimeInMillis()	{		return bindTime;	}	/**	 * Get the optimize time for the associated query in milliseconds.	 * 	 * @return long		The optimize time for the associated query in milliseconds.	 */	public long getOptimizeTimeInMillis()	{		return optimizeTime;	}	/**	 * Get the generate time for the associated query in milliseconds.	 * 	 * @return long		The generate time for the associated query in milliseconds.	 */	public long getGenerateTimeInMillis()	{		return generateTime;	}	/**	 * Get the timestamp for the beginning of compilation	 *	 * @return Timestamp	The timestamp for the beginning of compilation.	 */	public Timestamp getBeginCompileTimestamp()	{		return beginCompileTimestamp;	}	/**	 * Get the timestamp for the end of compilation	 *	 * @return Timestamp	The timestamp for the end of compilation.	 */	public Timestamp getEndCompileTimestamp()	{		return endCompileTimestamp;	}	void setCompileTimeWarnings(SQLWarning warnings) {		this.warnings = warnings;	}	public final SQLWarning getCompileTimeWarnings() {		return warnings;	}	/**	 * Set the compile time for this prepared statement.	 *	 * @param compileTime	The compile time	 *	 * @return Nothing.	 */	protected void setCompileTimeMillis(long parseTime, long bindTime,										long optimizeTime, 										long generateTime,										long compileTime,										Timestamp beginCompileTimestamp,										Timestamp endCompileTimestamp)	{		this.parseTime = parseTime;		this.bindTime = bindTime;		this.optimizeTime = optimizeTime;		this.generateTime = generateTime;		this.compileTime = compileTime;		this.beginCompileTimestamp = beginCompileTimestamp;		this.endCompileTimestamp = endCompileTimestamp;	}	/**		Finish marks a statement as totally unusable.	 */	public void finish(LanguageConnectionContext lcc) {		synchronized (this) {			inUseCount--;			if (cacheHolder != null)				return;			if (inUseCount != 0) {				//if (SanityManager.DEBUG) {				//	if (inUseCount < 0)				//		SanityManager.THROWASSERT("inUseCount is negative " + inUseCount + " for " + this);				//}				return; 			}		}					// invalidate any prepared statements that		// depended on this statement (including this one)		// prepareToInvalidate(this, DependencyManager.PREPARED_STATEMENT_INVALID);		try		{			/* NOTE: Since we are non-persistent, we "know" that no exception			 * will be thrown under us.			 */			makeInvalid(DependencyManager.PREPARED_STATEMENT_RELEASE, lcc);		}		catch (StandardException se)		{			if (SanityManager.DEBUG)			{				se.printStackTrace(System.out);				SanityManager.THROWASSERT(					"Unexpected exception - " + se);			}		}	}	/**	 *	Set the Execution constants. This routine is called as we Prepare the	 *	statement.	 *	 *	@param	ConstantAction	The big structure enclosing the Execution constants.	 */	public	final void	setConstantAction( ConstantAction constantAction )	{		executionConstants = constantAction;	}	/**	 *	Get the Execution constants. This routine is called at Execution time.	 *	 *	@return	ConstantAction	The big structure enclosing the Execution constants.	 */	public	final ConstantAction	getConstantAction()	{		return	executionConstants;	}	/**	 *	Set the saved objects. Called when compilation completes.	 *	 *	@param	objects	The objects to save from compilation	 */	public	final void	setSavedObjects( Object[] objects )	{		savedObjects = objects;	}	/**	 *	Get the specified saved object.	 *	 *	@param	objectNum	The object to get.	 *	@return	the requested saved object.	 */	public final Object	getSavedObject(int objectNum)	{		if (SanityManager.DEBUG) {			if (!(objectNum>=0 && objectNum<savedObjects.length))			SanityManager.THROWASSERT(				"request for savedObject entry "+objectNum+" invalid; "+				"savedObjects has "+savedObjects.length+" entries");		}		return	savedObjects[objectNum];	}	/**	 *	Get the saved objects.	 *	 *	@return all the saved objects	 */	public	final Object[]	getSavedObjects()	{		return	savedObjects;	}	//	// Dependent interface	//	/**		Check that all of the dependent's dependencies are valid.		@return true if the dependent is currently valid	 */	public boolean isValid() {		return isValid;	}	/**	 * set this prepared statement to be valid, currently used by	 * GenericTriggerExecutor.	 */	public void setValid()	{		isValid = true;	}	/**	 * Indicate this prepared statement is an SPS action, currently used	 * by GenericTriggerExecutor.	 */	public void setSPSAction()	{		spsAction = true;	}	/**		Prepare to mark the dependent as invalid (due to at least one of		its dependencies being invalid).		@param	action	The action causing the invalidation		@param	p		the provider		@exception StandardException thrown if unable to make it invalid	 */	public void prepareToInvalidate(Provider p, int action, 									LanguageConnectionContext lcc) 		throws StandardException {		/*			this statement can have other open result sets			if another one is closing without any problems.			It is not a problem to create an index when there is an open			result set, since it doesn't invalidate the access path that was			chosen for the result set.		*/		switch (action) {		case DependencyManager.CHANGED_CURSOR:		case DependencyManager.CREATE_INDEX:			return;		}		/* Verify that there are no activations with open result sets		 * on this prepared statement.		 */		lcc.verifyNoOpenResultSets(this, p, action);	}	/**		Mark the dependent as invalid (due to at least one of		its dependencies being invalid).		@param	action	The action causing the invalidation	 	@exception StandardException Standard Cloudscape error policy.	 */	public void makeInvalid(int action, LanguageConnectionContext lcc)		 throws StandardException	{		boolean alreadyInvalid;				synchronized (this) {			if (compilingStatement)				return;			alreadyInvalid = !isValid;					// make ourseleves invalid			isValid = false;			// block compiles while we are invalidating			compilingStatement = true;		}		try {			DependencyManager dm = lcc.getDataDictionary().getDependencyManager();			if (!alreadyInvalid)			{				dm.invalidateFor(this, action, lcc);			}			/* Clear out the old dependencies on this statement as we			 * will build the new set during the reprepare in makeValid().			 */			dm.clearDependencies(lcc, this);			/*			** If we are invalidating an EXECUTE STATEMENT because of a stale			** plan, we also need to invalidate the stored prepared statement.			*/			if (execStmtName != null) {				switch (action) {				case DependencyManager.INTERNAL_RECOMPILE_REQUEST:				case DependencyManager.CHANGED_CURSOR:				{					/*					** Get the DataDictionary, so we can get the descriptor for					** the SPP to invalidate it.					*/					DataDictionary dd = lcc.getDataDictionary();											SchemaDescriptor sd = dd.getSchemaDescriptor(execSchemaName, lcc.getTransactionCompile(), true);					SPSDescriptor spsd = dd.getSPSDescriptor(execStmtName, sd);					spsd.makeInvalid(action, lcc);					break;				}				}			}		} finally {			synchronized (this) {				compilingStatement = false;				notifyAll();			}		}	}	/**		Attempt to revalidate the dependent. For prepared statements,		this could go through its dependencies and check that they		are up to date; if not, it would recompile the statement.		Any failure during this attempt should throw		StandardException.unableToRevalidate().		@exception StandardException thrown if unable to make it valid	 */	public void makeValid(LanguageConnectionContext lcc) 		throws StandardException 	{		PreparedStatement ps;		// REMIND: will want to go through dependency list		// and check if we can make it valid just on faith,		// i.e. when it was marked 'possibly invalid' due		// to a rollback or some similar action.		// this ends up calling makeValid(qt, ac) below:		ps = statement.prepare(lcc);		if (SanityManager.DEBUG)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -