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

📄 brokeredconnection.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public final PreparedStatement prepareStatement(String sql, int resultSetType, 					int resultSetConcurrency)       throws SQLException	{		try		{			return control.wrapStatement(getRealConnection().				prepareStatement(sql, resultSetType, resultSetConcurrency), sql, null);		}		catch (SQLException se)		{			notifyException(se);			throw se;		}	}    public final CallableStatement prepareCall(String sql, int resultSetType, 				 int resultSetConcurrency) throws SQLException	{		try		{			return control.wrapStatement(getRealConnection().				prepareCall(sql, resultSetType, resultSetConcurrency), sql);		}		catch (SQLException se)		{			notifyException(se);			throw se;		}	}    public final java.util.Map getTypeMap() throws SQLException	{		try		{			return getRealConnection().getTypeMap();		}		catch (SQLException se)		{			notifyException(se);			throw se;		}	}    public final void setTypeMap(java.util.Map map) throws SQLException	{		try		{			getRealConnection().setTypeMap(map);		}		catch (SQLException se)		{			notifyException(se);			throw se;		}	}	/////////////////////////////////////////////////////////////////////////	//	//	MINIONS	//	/////////////////////////////////////////////////////////////////////////	/**	  *	A little indirection for getting the real connection. 	  *	  *	@return	the current connection	  */	final EngineConnection getRealConnection() throws SQLException {		if (isClosed)			throw Util.noCurrentConnection();		return control.getRealConnection();	}	protected final void notifyException(SQLException sqle) {		if (!isClosed)			control.notifyException(sqle);	}	/**		Sync up the state of the underlying connection		with the state of this new handle.	*/	public void syncState() throws SQLException {		EngineConnection conn = getRealConnection();		stateIsolationLevel = conn.getTransactionIsolation();		stateReadOnly = conn.isReadOnly();		stateAutoCommit = conn.getAutoCommit();        stateHoldability = conn.getHoldability(); 	}	/**		Isolation level state in BrokeredConnection can get out of sync		if the isolation is set using SQL rather than JDBC. In order to		ensure correct state level information, this method is called		at the start and end of a global transaction.	*/	public void getIsolationUptoDate() throws SQLException {		if (control.isIsolationLevelSetUsingSQLorJDBC()) {			stateIsolationLevel = getRealConnection().getTransactionIsolation();			control.resetIsolationLevelFlag();		}	}	/**		Set the state of the underlying connection according to the		state of this connection's view of state.		@param complete If true set the complete state of the underlying		Connection, otherwise set only the Connection related state (ie.		the non-transaction specific state).	*/	public void setState(boolean complete) throws SQLException {		Class[] CONN_PARAM = { Integer.TYPE };		Object[] CONN_ARG = { new Integer(stateHoldability)};		Connection conn = getRealConnection();		if (complete) {			conn.setTransactionIsolation(stateIsolationLevel);			conn.setReadOnly(stateReadOnly);			conn.setAutoCommit(stateAutoCommit);			// make the underlying connection pick my holdability state			// since holdability is a state of the connection handle			// not the underlying transaction.			// jdk13 does not have Connection.setHoldability method and hence using			// reflection to cover both jdk13 and higher jdks			try {				Method sh = conn.getClass().getMethod("setHoldability", CONN_PARAM);				sh.invoke(conn, CONN_ARG);			} catch( Exception e)			{				throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e));			}		}	}	public BrokeredStatement newBrokeredStatement(BrokeredStatementControl statementControl) throws SQLException {		return new BrokeredStatement(statementControl, getJDBCLevel());	}	public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException {		return new BrokeredPreparedStatement(statementControl, getJDBCLevel(), sql);	}	public BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql) throws SQLException {		return new BrokeredCallableStatement(statementControl, getJDBCLevel(), sql);	}	/**	 *  set the DrdaId for this connection. The drdaID prints with the 	 *  statement text to the errror log	 *  @param drdaID  drdaID to be used for this connection	 *	 */	public final void setDrdaID(String drdaID)	{        try {		    getRealConnection().setDrdaID(drdaID);        } catch (SQLException sqle)        {            // connection is closed, just ignore drdaId            // since connection cannot be used.        }	}	/**	 *  Set the internal isolation level to use for preparing statements.	 *  Subsequent prepares will use this isoalation level	 * @param level - internal isolation level 	 * @throws SQLException	 * @see EmbedConnection#setPrepareIsolation	 * 	 */	public final void setPrepareIsolation(int level) throws SQLException	{        getRealConnection().setPrepareIsolation(level);	}	/**	 * get the isolation level that is currently being used to prepare 	 * statements (used for network server)	 * 	 * @throws SQLException	 * @return current prepare isolation level 	 * @see EmbedConnection#getPrepareIsolation	 */	public final int getPrepareIsolation() throws SQLException	{		return getRealConnection().getPrepareIsolation();	}        /**     * Add a SQLWarning to this Connection object.     * @throws SQLException      */    public final void addWarning(SQLWarning w) throws SQLException    {        getRealConnection().addWarning(w);    }                /**     * Get the string representation for the underlying physical     * connection.     *     *  When a physical connection is created, it is assigned a unique id      *  that is unchanged for the lifetime of the connection. When an      *  application calls Connection.toString(), it gets the string      *  representation of the underlying physical connection, regardless      *  of whether the application has a reference to the physical connection      *  itself or a reference to a proxy connection (aka brokered connection)      *  that wraps the physical connection.     *     *  Since this BrokeredConnection is a proxy connection, we return the     *  string value of its underlying physical connection     *      * @return unique string representation of the underlying     *   physical connection     */    public String toString()     {        try        {            return getRealConnection().toString();        }        catch ( SQLException e )        {            return "<no connection>";        }    }	protected int getJDBCLevel() { return 2;}    /*     * JDBC 3.0 methods that are exposed through EngineConnection.     */        /**     * Prepare statement with explicit holdability.     */    public final PreparedStatement prepareStatement(String sql,            int resultSetType, int resultSetConcurrency,            int resultSetHoldability) throws SQLException {    	try {            resultSetHoldability = statementHoldabilityCheck(resultSetHoldability);    		    		return control.wrapStatement(    			getRealConnection().prepareStatement(sql, resultSetType,                        resultSetConcurrency, resultSetHoldability), sql, null);    	}    	catch (SQLException se)    	{    		notifyException(se);    		throw se;    	}    }    /**     * Get the holdability for statements created by this connection     * when holdability is not passed in.     */    public final int getHoldability() throws SQLException {    	try {    		return getRealConnection().getHoldability();    	}    	catch (SQLException se)    	{    		notifyException(se);    		throw se;    	}    }        /*    ** Methods private to the class.    */        /**     * Check the result set holdability when creating a statement     * object. Section 16.1.3.1 of JDBC 4.0 (proposed final draft)     * says the driver may change the holdabilty and add a SQLWarning     * to the Connection object.     *      * This work-in-progress implementation throws an exception     * to match the old behaviour just as part of incremental development.     */    final int statementHoldabilityCheck(int resultSetHoldability)        throws SQLException    {        int holdability = control.checkHoldCursors(resultSetHoldability, true);        if (holdability != resultSetHoldability) {            SQLWarning w =                 EmbedSQLWarning.newEmbedSQLWarning(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);                        addWarning(w);        }                return holdability;            }}

⌨️ 快捷键说明

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