Download Oracle Providers for ASP.NET

Document related concepts

Extensible Storage Engine wikipedia , lookup

Tandem Computers wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Concurrency control wikipedia , lookup

Microsoft Access wikipedia , lookup

Database wikipedia , lookup

Team Foundation Server wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database model wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

SQL wikipedia , lookup

Oracle Database wikipedia , lookup

PL/SQL wikipedia , lookup

Transcript
Oracle in the .NET
Environment
<Insert Picture Here>
Tomer Avissar
Senior Support consultant
[email protected]
http://oracleatdotnet.blogspot.com
Agenda
• Oracle and Microsoft
• Oracle and .NET Getting Started
• PL/SQL Development Lifecycle with
Visual Studio
• Oracle Data Provider for .NET (ODP.NET)
• Oracle Providers for ASP.NET
• .NET Stored Procedures
<Insert Picture Here>
<Insert Picture Here>
Oracle and Microsoft –
Collaborating Today and in
the Future
Oracle’s Commitment to .NET
Visual
.NET
Studio
Stored
ODAC
.NET Plug- Procedures 2006
ins
ODP.NET
ODP.NET
2002
2003
Q2 2005
.NET 1.0
.NET 1.1
VS 2003
Q3 2005
Q3 2006
64-bit
ODP.NET
ODAC 11g
Q1 2007 2007, 2008
.NET 2.0 & .NET 3.0 Windows
VS 2005
Vista, Win2k8
Relationship with Microsoft
Engineering
• Close collaboration with MS Engineering teams
• Access to pre-release drops of Microsoft products
• VSIP Premier Marketing partner
Marketing
• Sponsorship at respective events
• Joint training, road shows, collateral etc.
Support
• Microsoft Premier Support Agreement
• Collaboration of support teams
<Insert Picture Here>
Dewey Forrester
Director, Platform
Evangelism Microsoft
“We do not let the areas of
competition get in the way of the
areas in which we can bring a
great combined offering to
market.”
<Insert Picture Here>
Oracle and .NET –
Getting Started
Oracle Technology Network –
.NET Developer Center
• http://otn.oracle.com/dotnet
• Free downloads of Visual Studio tools, ODP.NET and
Oracle Database XE.
• Whitepapers
• Sample Code
• Demo Videos
• Help Forums
• “How to” step by step tutorials
• Latest Oracle on .NET News
.NET Development Environment Support
Oracle Providers
for ASP.NET
Oracle Developer
Tools for VS.NET
Develop
Visual Studio
Environment
IIS
C++, C#,
VB .NET
Application
MTS/
Deploy (ASP.NET) COM+
Application
Deploy
IIS
Database
Development
Oracle Data
Provider for .NET
Oracle Database
Extensions for .NET
Develop on Windows, Database on any
Platform
ODT and
ODP.NET
Windows
Linux
Visual Studio
Environment
Unix
Windows
Other
Oracle 11g,10g, 9i, or 8i
<Insert Picture Here>
PL/SQL Development
Lifecycle with Visual Studio
SQL and PL/SQL Development Lifecycle
• Create Schema Objects, PL/SQL procedures,
functions, packages
• Oracle Wizards – eg Oracle Stored Procedure Wizard, Table
Designer
• Query Window – Ad Hoc SQL
• Microsoft Query Designer
• Run SQL*Plus Script for existing scripts
• Create Roles and grant privileges to them
• Grant and Revoke Privileges Wizard
• Create SQL and PL/SQL scripts
• Generate Create Script from existing schema objects
• Store scripts in source control
• Oracle Database Project
SQL and PL/SQL Development Lifecycle
• Edit SQL and PL/SQL Scripts
• Oracle SQL Editor – file based
• Oracle PL/SQL Editor – database based
• Tune SQL
• Explain plan feature in Oracle Query Window
• Create client side .NET code
• (C#, VB.NET, ASP.NET)
• Use Oracle Data Provider for .NET to call PL/SQL
• Debug .NET and PL/SQL together
• PL/SQL Debugger in Visual Studio
• Deploy
PL/SQL Development Lifecycle
• Oracle Developer Tools for Visual Studio
• Tightly integrated “Add-in” for Visual Studio 2008/2005 and
Visual Studio .NET 2003
• ODP.NET
• ADO.NET compliant data provider
• Native access to Oracle database
• Utilize advanced Oracle Database features
• RAC, performance, security, data types, XML, etc.
• Both available for free download today
• http://otn.oracle.com/dotnet
PL/SQL Development Lifecycle
Oracle Developer Tools for Visual Studio
• Fully integrated with Visual Studio 2008 and 2005
• Fully integrated with Visual Studio .NET 2003
• Oracle Explorer
•
•
•
•
Automatic code generation – Winform and ASP.NET
Oracle Wizards and Designers
Oracle Data Window
Oracle Database Project
• Edit and Run SQL scripts
• SQL*Plus is built in
• Source control integration
PL/SQL Development Lifecycle
Oracle Developer Tools for Visual Studio
• Integrated PL/SQL Editor and Debugger
• Oracle Query Window
• Ad Hoc SQL
• Explain Plan
• .NET Stored Procedure Deployment
• Integrated help system – SQL, PL/SQL keywords
D E M O N S T R A T I O N
PL/SQL Lifecycle
Create Schema Objects
• Oracle Wizards
•
•
•
•
Table Designer
PL/SQL Package Wizard
Table Import Wizard to import data
..many others (one Wizard/Designer for every schema type)
• Run SQL*Plus Script
D E M O N S T R A T I O N
Creating Schema
Objects
Create Roles and Grant Privileges
• Oracle Query Window
• Grant and Revoke Privileges Dialog
D E M O N S T R A T I O N
Privileges Wizard
Visual Studio Source Control
Integration
• Configuring Source Control in Visual Studio
• Generate Create Script to Source Control
• Oracle Database Project Features
D E M O N S T R A T I O N
Source Control
Integration
PL/SQL and SQL Editing
• Oracle PL/SQL Editor – database based
•
•
•
•
Collapsible Regions
Syntax Coloring
Integrated Online Help
Supports Debugging
• Oracle SQL Editor – file based
D E M O N S T R A T I O N
SQL and PL/SQL
Editors
SQL Tuning
• Explain Plan feature in Oracle Query Window
• Options page to choose what metrics to see
D E M O N S T R A T I O N
SQL Tuning
PL/SQL Debugging in Visual Studio
• Direct Database Debugging
• “Step into” a SP directly from Server Explorer
• Application Debugging
• Step from application code (eg C# or ASP.NET code)
directly into PL/SQL and then return back
• External Application Debugging
• Set breakpoints and debug SPs called by external
applications running on other machines or platforms
PL/SQL Debugging Configuration
• GRANT debug privileges as SYSDBA
• 9.2, 10g: GRANT DEBUG ANY PROCEDURE TO username
• 10g: GRANT DEBUG CONNECT SESSION TO username
• Set port range in Debugging Options page
• Tools -> Options->Oracle Developer Tools
• Compile PL/SQL units for Debug
• Via menu in PL/SQL editor or in Oracle Explorer
Direct Database Debugging
• “Step Into” from Server Explorer
• “Run Debug” from Server Explorer
• Enter parameters manually
Application Debugging Mode
• Step from .NET code into PL/SQL and back
• Check off “Tools -> Oracle Application Debugging”
• ODT automatically starts listener using port in range
given in Options page
• Uncheck "Enable the Visual Studio hosting process"
in the .NET Project Properties Debug tab
D E M O N S T R A T I O N
PL/SQL
Debugging
<Insert Picture Here>
Oracle Data Provider for .NET
(ODP.NET)
ODP.NET - Basics
• Supports Oracle8i and higher Oracle DB Server
• DB server can be on any operating system
• Uses 9.2 client or higher
• Database client on Windows
• Supports 32-bit, 64-bit x64, and 64-bit Itanium
• Available as free download
• http://otn.oracle.com/dotnet
ODP.NET Object Model
Disconnected
Layer
DataSet
Connected Layer
(ODP.NET)
Oracle
DataAdapter
Data
Layer
Oracle
CommandBuilde
r
Oracle
DataReader
Oracle
Command
Oracle
Transaction
Oracle
Connection
Oracle
D E M O N S T R A T I O N
ODP.NET
ODP.NET Features
• Full PL/SQL support
• Packaged, non-packaged, anonymous, autonomous
• Batch SQL available with anonymous PL/SQL
• Native Oracle data types
• REF Cursors, LOBs, XMLType, TimeStamp, etc.
• Safe type mapping to .NET data types
• Connection pooling
• Min, Max, Timeout, Lifetime, Increment, Decrement
ODP.NET Features
• Transactions
•
•
•
•
Enterprise Services via Oracle Services for MTS
Local (Implicit and Explicit)
System.Transactions
Savepoints
• Parameters
• PL/SQL Associative Array data type
• LOBs
• Ability to pre-fetch or defer LOB retrieval
ODP.NET Features
• XML
• XMLType data type
• Query and Save XML from the DB
• Both relational and object-relational
• Interoperate with MS XML APIs (e.g. XmlReader)
• Supports XSLT, XPATH, and XML Schema
• RAC
• Automatic load balancing
• Automatic connection cleanup
ODP.NET Features
•
•
Database Change Notification
Performance Tuning
•
•
•
•
Statement caching
FetchSize and RowSize
64-bit AMD64/EM64T and Itanium
Security
•
•
Proxy authentication
Application security context
<Insert Picture Here>
ODP.NET Performance
Features
Connection Pool
• Min Pool Size = # connections at steady state or average
load
• Max Pool Size = # connections at maximum capacity
•
Min and Max Pool Size always obeyed ahead of other CP
parameters
• Incr Pool Size = connection growth rate from steady state
• Decr Pool Size = connection decrease rate from steady state
•
Pool size checked every 3 minutes
• Validate Connection = should be false in most cases
•
•
Extra round trip
Writing your own exception handler is likely faster
ODP.NET Connection Pool Monitoring
• Monitor CP via ODP.NET performance counters
and/or tracing
• Counters available with ODP.NET 11.1.0.6.20 or higher
Multiple Users – One Connection Pool
to Unite Them All
• Use proxy authentication
•
•
•
Effective for uniquely-identified users or groups
of users, while maintaining CP benefits
Has numerous security benefits
Creates two sessions, but uses one connection
• Use application context
•
•
•
Distinguishes individuals in connection pool with
a string identifier
Set OracleConnection.ClientId, ActionName,
and/or ModuleName
Lighter weight than proxy authentication, but
does not provide as fine grained security features
Commands – Bind Variables
• Bind variables
•
•
Prevents re-parsing of frequently executed statements
Works with SQL and PL/SQL statements
• Improves subsequent command executions
•
•
Literal value changes in commands forces a re-parse
and re-optimization
Literal values should become bind variables
• Executed statements stored in Oracle shared pool
•
Re-parsing and re-optimization uses CPU and requires
shared pool locks
Commands – Statement Caching
• Statement caching
•
•
•
Retains parsed statement in shared pool
Cursor stays open on the client side for faster re-use
• No additional lookup needed on server
Metadata remains on the client
• Caches most recently used statements
•
Works with SQL and PL/SQL statements
• Best used with bind variables
• From ODP.NET 10.2.0.2.20, on by default
•
Caches the last ten executed statements
• Developer can choose which statements to cache
D E M O N S T R A T I O N
Statement
Caching
Commands – Data Retrieval
• Control how much data is retrieved per DB
roundtrip
•
•
Too much data retrieved – excessive client-side memory
used
Too little data retrieved – additional round trips
• Use OracleCommand.RowSize and
OracleDataReader.FetchSize to control result size
•
•
RowSize populated after statement execution
• Set dynamically at run-time
FetchSize can be set as multiple of RowSize
D E M O N S T R A T I O N
Fetch Size and
Row Size
Commands – Mass Data Movement
with Arrays
• PL/SQL associative arrays
•
Pass large amounts of data between .NET and DB of the
same data type
• Use parameter array binding
•
•
•
Useful if executing the same statement multiple times
Bind variables are the same, variable values can be
different
One execution for each element in the bound array
• Remember: PL/SQL associative arrays and
parameter array binding are two different concepts
Commands – Statement Batching
• Execute multiple commands in one DB roundtrip
• Use anonymous PL/SQL
•
Useful for disparate or similar statements
• Use OracleDataAdapter.UpdateBatchSize to batch
updates from DataSet
REF Cursors
• Retrieve data as needed
• Control data retrieved via FetchSize
• Fill a DataSet with just a portion of the REF Cursor result
• Explicit control over what REF Cursor data is retrieved and
how
• Defers result set retrieval until needed
• Pass REF Cursors back as input stored procedure
parameters
• OracleRefCursor class
D E M O N S T R A T I O N
Batch Processing
LOBs
• Data retrieval options
• Defer retrieval (default) with LOB locator
• Retrieve data immediately using
OracleCommand.InitialLOBFetchSize
• Retrieve a portion using Read method
• Use Search method to find data to be retrieved
• Update/Insert/Delete
• Modify LOB without retrieving the data to the client side
• Uses LOB locator
• Use SecureFile data type in Oracle Database 11g
ODP.NET: Promotable Transactions
• Problem: At design time, unknown if a transaction
will be distributed or local at run time
• Must use distributed transactions even if local transactions
are used some of the time
• Local transactions are less resource intensive
• Preferred over distributed transactions
• Solution: Promote local transactions to distributed
as needed at run time
• Benefits
• Better application performance
• Lower resource usage
ODP.NET: Promotable Transactions
• Enabled by default
• No code changes required
• Just upgrade ODP.NET
• Requirements
• First connection to Oracle Database 11g (11.1) or higher
• Subsequent connections can be to any other version or
database
• Requires Oracle Services for MTS 11.1.0.7.20
• Requires .NET Framework 2.0 or higher
Additional Optimizations
•
Oracle Database Change Notification
•
•
•
Maintain consistent client cache while disconnected
from server
Programmatically control caching and updating
Oracle Client Result Cache
•
Transparent client cache
<Insert Picture Here>
Oracle Providers for ASP.NET
Oracle Providers for ASP.NET
•
ASP.NET Providers
•
•
•
•
Pre-built services to store website state into databases
Easy to learn
• Based on standard ASP.NET provider APIs and
schema
Can be managed by IIS
• Membership and role information
Installation
• Run PL/SQL scripts to create provider schemas
Oracle Providers for ASP.NET
•
Oracle Providers for ASP.NET Components
•
•
•
•
•
•
•
•
•
Cache Dependency Provider
Membership Provider
Profile Provider
Role Provider
Site Map Provider
Session State Provider
Web Parts Personalization Provider
Web Events Provider
Administrators can pick and choose which providers
to use
<Insert Picture Here>
.NET Stored Procedures
Oracle Database Extensions for .NET
• Database option
• DB server on Windows only
• Both 32-bit and 64-bit supported
• Oracle Database 10g Release 2 or later
Oracle Database Extensions for .NET
Oracle
Developer
Tools
Oracle
Developer
for
Visual
.NET
Tools
forStudio
VS.NET
Visual Studio
Environment
Client
Application
Develop
Invoke
C#,VB.NET,C++
Server Project
(Use ODP.NET
if required)
Invoke
Stored
Procedure,
SQL ..
Build
Assembly
foo.dll
(proc sp)
Oracle Database
Oracle
Database
Extensions for .NET
Extensions for .NET
Deploy
Stored Proc
Useful Links
• OTN (Oracle Technology Network)
• http://otn.oracle.com
• .NET page on the OTN (Oracle Technology
Network)
• http://otn.oracle.com/dotnet
• Direct Links
• ODP.NET
• Oracle Express (XE)