Software: Apache. PHP/5.5.15 uname -a: Windows NT SVR-DMZ 6.1 build 7600 (Windows Server 2008 R2 Enterprise Edition) i586 SYSTEM Safe-mode: OFF (not secure) E:\oracle\product\10.2.0\client_2\sqlj\doc\ drwxrwxrwx |
Viewing file: sqlj-conn-beans.html (9.65 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) | SQLJ-Specific JSP Connection BeansSQLJ-specific connection beans are available in runtime12ee.jar or runtime12ee.zip.In OracleJSP, the connection beans support the API getConnection() that returns JDBC connections. Specifically, there are two connection beans in OracleJSP: oracle.jsp.dbutil.ConnBean,SQLJ-specific connection beans extends the original connection beans with APIs that returns SQLJ connection contexts in OracleJSP applications. Specifically, there are two SQLJ-specific connection beans: oracle.sqlj.runtime.SqljConnBean,
Both SQLJ-specific connection beans support a new bean property ContextClass of Type java.lang.Class and the following APIs: public synchronized void setContextClass(Class contextClass)The bean property ContextClass indicates type of the connection context returned by getContext() method call. By default, the value of the bean property ContextClass is sqlj.runtime.ref.DefaultContext. The setContextClass() and getContextClass() methods are setter and getter of that bean property. The getDefaultContext() and getContext() methods are handled
differently for SqljConnBean and SqljConnCacheBean. Below,
we discuss the handling of the two methods for SqljConnBean and
SqljConnCacheBean
respectively.
SqljConnBeanA SqljConnBean instance can issue only one logical JDBC connection. Multiple invocations of the getConnection method will return the same logical JDBC connection. Since a connection context created by a SqljConnBean instance is associated with a logical JDBC connection created by that SqljConnBena instance, the behavior of getDefaultContext and getContext needs to mimic that of the getConnection, i.e., a SqljConnBean instance has only one active connection context.The getDefaultContext() method returns a DefaultContext instance. The getContext() methods returns a connection context of the type specified by the ContextClass bean property. The first getDefaultContext() or getContext() method call will create and return a connection context based on the JDBC connection associated with the connection bean. The returned connection context will also be stored in the SqljConnBean instance. Once a connection context has been created and stored, the behaviour of subsequent getDefaultContext() method calls will depend on the type of the stored connection context. If the stored connection context is a DefaultContext instance, getDefaultContext() will return the stored connection context. If the stored connection context is not a DefaultContext instance, getDefaultContext() will close the stored connection context, reuse the JDBC connection associated with that stored connection context to create and return a new connection context. Once a connection context has been created and stored, the behaviour of subsequent getContext() method calls will depend on the type of the stored connection context and the current setting of the ContextClass bean property. If the stored connection context is of the same type as specified by ContextClass, getContext() will return the stored connection context. If the stored connection context is not of the type specified by ContextClass, getContext() will close the stored connection context, reuse the JDBC connection associated with the stored connection context to create and return a new connection context. A newly created connection context is stored to replace the previously stored connection context. As mentioned before, at one time, only one active connection context is allowd for a SqljConnBean instance. Closing the logical JDBC connection instantiated by a SqljConnBean instance will force any active connection context in that to SqljConnBean instance be shutdown. Closing a connection context using close() or close(ConnectionContext.CLOSE_CONNECTION) will shutdown the associated JDBC connection, while closing a connection context using close(ConnectionContext.KEEP_CONNECTION) will keep the associated JDBC connection active. SqljConnCacheBeanUnlike SqljConnBean, SqljConnCacheBean creates and returns a new logical JDBC connection for each invocation of the getConnection method. The getDefaultContext or getContext methods mimic the behavior of getConnection. I.e., Each getDefaultContext or getContext call creates a new connection context.Closing a logical JDBC connection created by a SqljConnCacheBean instance will shutdown the connection context associated with that JDBC connection. Closing a connection context using close() or close(ConnectionContext.CLOSE_CONNECTION) will shutdown the associated JDBC connection, while closing a connection context using close(ConnectionContext.KEEP_CONNECTION) will keep the associated JDBC connection active. ExampleThe following program, SQLJSelectInto.sqljsp, demonstrates the usage of the usage of SqljConnCacheBean, its ContextClass bean properties, and its getContext() API.<%@ page language="sqlj" |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0312 ]-- |