* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Connection Caching
Microsoft SQL Server wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Relational model wikipedia , lookup
Concurrency control wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Oracle Database wikipedia , lookup
Kuassi Mensah
Rajkumar Irudayaraj
Java Products Group
Oracle Corporation
Oracle Database 10g JDBC
Best-of-Breed Drivers for Java,
J2EE, Web Services and GRID
Agenda
Oracle Database 10g JDBC Overview
Implicit Connection Cache
Fast Connection Fail-Over
Agenda
Oracle Database 10g JDBC Overview
•
•
•
•
•
Re-Architecture Groundwork
Database Connectivity for Java, J2EE, Web Services and
GRID
Tighter Integration with the Oracle Database
Feature Consistency across Type-2 and Type-4 Drivers
Miscellaneous Enhancements
Implicit Connection Cache
Fast Connection Fail-Over
Re-Architecture Ground Work
Reduce functional gap between drivers
Faster JDBC Application Execution
–
–
–
–
Reduced Code Path
Reduced Java intermediate and Temporary
Objects
Caching and Reusing
Optimized Conversion Operations
Fastest JDBC Drivers,
Best SPECJApp2002 results
Comprehensive Support for
JDBC 3.0
Oracle Database 9i R2 JDBC
–
–
–
–
Transaction Savepoint
Toggling between Local and Global transactions
Reuse of PreparedStatement
JDK 1.4.x support for JDBC Clients
Oracle Database 10g JDBC
–
–
–
–
–
Named Parameters
DataLink URL
New Ref interface
J2EE Connector Architecture Resource Adapter
Web Rowset (JSR-114 Public Draft)
Database Connectivity for
Web Services
Web Services Support
–
–
JDBC 3.0 Web RowSet (JSR-114 Public Draft)
Database Web Services Call-in
GRID Computing Support
–
–
Dynamic Load-balancing across RAC/GRID
Transparent Session Migration for GRID (Future)
JSR-114 JDBC RowSet
JDBCRowSet
EJB
Servlet
CachedRowSet
WebRowSet
FilteredRowSet
Web
Services
JDBC WebRowSet - Definition
An implementation of JSR-114, extends
java.sql.ResultSet capabilities
–
–
–
–
–
Enables reading and writing result sets from/into XML
format
Serializable/Distributable
Disconnected, decoupled from Data Source
Extensible to non-tabular data
Can be shipped over Internet using HTTP/XML protocols
JDBC WebRowSet - Example
//create a resultSet to populate RowSet
stmt = conn.createStatement();
rs = stmt.executeQuery("select ...");
OracleWebRowSet wrs = new OracleWebRowSet();
// populate the RowSet
wrs.populate(rs);
// close the connection
conn.close();
// RowSet still contains values...
wrs.next();
Object col1 = wrs.getObject(1);
// write the RowSet out as XML
wrs.writeXML(out);
Database as Web Services
Provider
J2EE
(Business Logic)
Oracle
Database 10g
Web
Service
Client
SOAP
Oracle
Application
Server
10g
JDBC
Oracle9iAS
Web
PL/SQL
Services
Data
Framework
SQL/DML
Java
DataSQL/Query
Logic
AQ/Streams
Database Connectivity for
RAC/GRID
Dynamic Load-balancing across RAC/GRID
–
Fast Connection Fail-Over
Transparent Session Migration for GRID
–
Migrate Sessions across instances of the same
database (Future)
Tighter Integration with the
Oracle Database
Manageability/Ease of Use
–
–
–
End-to-End Tracing support
Enhanced Datum support
Easy Type-2 Driver Install
New and Enhanced Data Types
–
–
–
–
–
Native IEEE DOUBLE and FLOAT
INTERVAL-DAY-TO-SECOND
Enhanced VARRY
LONG-to-LOB Conversion
Unlimited LOB size
Feature Consistency across
Type-2 and Type-4 Drivers
“Thin” Reducing the gap with “OCI”
–
–
–
–
–
–
PL/SQL Index-By table support
New Encryption algorithms: 3DES112 &
3DES168
Direct XA: performance optimizations for XA
operations
Proxy Authentication
RAC/HA support: Fast Connection Fail-Over
Starting/Stopping the Database
Miscellaneous
System Properties to set CHAR/NCHAR
behavior
Stop shipping classes111 and zip files
NLS Repackaging
Agenda
• Oracle Database 10g JDBC Overview
Implicit Connection Cache
•
•
•
•
•
•
Connection Caching: 9i R2 versus 10g
Transparent Access to the Cache
Connection Retrieval based on User-Defined
Attributes
Handling Abandoned Connections
Connection Cache Manager
Advanced Features
Fast Connection Fail-Over
Connection Caching: 9i R2
versus 10g Connection
Connection Caching
9i R2
10g
Transparent Cache Access
No
Yes
Refresh Stale Connections
No
Yes
Attributes based Conn. Retrieval
No
Yes
Reclaim/Reuse Abandoned Conn.
No
Yes
Heterogeneous User/Password
No
Yes
Centralized Cache Management
No
Yes
Transparent Access to the
Connection Cache
Standard DataSource getConnection() APIs
retrieve cached Connections
Example:
ods.setUSer(“scott”);
ods.setConnectionCachingEnabled(true);
ctx.bind(“MyDS”, ods);
…
ds = (OracleDataSource) ctx.lookup(“MyDS”);
conn.getConnection(); // transparent cache creation and access
…
conn.close(); // return connection to the cache
…
ds.close(); // finally, close cache enabled DataSource
Connection Attributes Support
Request connection from cache based on
user-defined attributes
–
getConnection(java.util.Properties connAttr)
Support to associate user-defined attributes on a
connection for future retrieval
–
–
applyConnectionAttributes(java.util.Properties
connAttr)
close(java.util.Properties connAttr)
Get unmatched attributes on the retrieved connection
–
java.util.Properties
getUnMatchedConnectionAttributes()
Connection Attributes
Support…
Example:
// Multiple attributes may be specified
connAttr.setProperty(“NLS_LANG”, “ISO-LATIN-1”);
connAttr.setProperty(“TRANSACTION_ISOLATION”, “SERIALIZABLE”);
…
conn = getConnection(connAttr); // retrieve connection
…
// get UnMatched attributes from the retrieved connection
// May need to initialize the required attributes that did not match
java.util.Properties unMatchedAttr =
conn.getUnMatchedConnectionAttributes();
…
conn.close(connAttr); // close the connection
Abandoned Connection
Timeout Support
Helps reclaim abandoned or orphaned connections
checked out from the cache
Support enabled by setting AbandonedConnectionTimeout
property on the cache
JDBC monitors heart beat based on activity to the
database, such as stmt.execute().
Connection is reclaimed and returned to the cache, if
connection is inactive for the specified period
Connection Cache Manager
mid-tier Node
Oracle JDBC Driver
Cache# 1
Session 1.1
....
Session 1.m
...
Cache Manager
Cache# n
Session n.1
....
Session n.m
Connection Cache Manager…
Centralized Connection Cache Management
Handles cache management from creation
until death.
Allows dynamic cache reconfiguration.
Supports retrieval of number of checked out
or available connections
Supports and manages multiple caches
Advanced Features
Connection Attributes support based on weights
–
Allows assignment of weights to attributes for
selective retrieval of connections from cache.
Support for new Cache property
–
to assign weights to connection Attributes:
java.util.Properties CacheAttributeWeights
Support for Connection Cache Callbacks
–
for AbandonedConnectionCallback and
ReleaseConnectionCallback
Agenda
• Oracle Database 10g JDBC Overview
• Implicit Connection Caching
Fast Connection Fail-Over
Fast Connection Fail-over
–
–
–
Resilient connections – Rapid detection and
cleanup of invalid connections in the cache
This is achieved by handling RAC Service/Host
DOWN events
Load Balancing of connections for Service UP
events
Fast Connection Failover
Failed Database Connections
New Database Connections
Fail-over Scenario
Java/J2EE
ERP
Instance#1
Inst 1
Pre Fail-over
Post Fail-Over
Inst 2
Inst 3
Inst 4
Fast Connection Fail-over
Processing Connection Cache Manager
1
Connection
cache objects
Start/Stop
Publish
2
Subscribe
ONS
Daemon
3
4
handleEvent()
Failover Event
HandlerThread
Threads process events,
one per cache
5
..
Connection
objects
..
..
Fast Connection Fail-over
Processing…
New DataSource property:
ConnectionFailoverEnabled must be set to true
Works in conjunction with Implicit Connection
Caching, to process connections efficiently
Each connection is mapped to its Instance Name and
Host Name.
Processes Service UP/DOWN and Host DOWN
events.
Process events one at a time – guaranteed
processing.
Fast Connection Fail-over
Processing…
One Worker thread per Connection Cache handles event
processing – more efficient
First pass
–
Connections are marked as down first, to efficiently disable bad
connections
Second pass
–
Cleans up connections that are marked as bad
Applications in the middle of a Transaction are thrown a
SQL Exception, and the Transaction is rolled back
Service UP event initiates connections to be Load
Balanced to all active RAC instances
Fast Connection Fail-over
(FCF) vs. TAF
Connection Retries:
-
FCF allows retry at the Application level, whereas TAF
retries occur at the OCI/Net layer. Application layer
(Example: EJB Container) fully controls retries
Integrated with the Connection Cache:
-
Unlike TAF, FCF works in conjunction with the Implicit
Connection Cache, and has complete control over
connections managed by the cache
RAC Events Based:
-
FCF is a RAC event based mechanism. This is much more
efficient than detecting failures of network calls
Load Balancing Support:
-
FCF supports UP event Load Balancing of connections
across active RAC instances
JDBC Summary
Best performing JDBC drivers
Hassle-Free Install and Upgrade
Faster Development
–
Best Database Connectivity for Java, J2EE,
Web Services and GRID
Tighter Integration with the Oracle Database
Feature Rich Implicit Connection Cache
RAC Events based Fast Connection Fail-Over
Feature consistency across type-2 and type-4
JDBC drivers
–
Allows the flexibility of using different flavor of
JDBC drivers for development and deployment
More on TheServerSide.com
J2EE Community
News
Articles
Design Patterns
Benchmarks
Case Studies
Free PDFs of popular books
QUESTIONS
ANSWERS