An Oracle White Paper September Java Developers Perspective on Oracle Database 11g - PDF

Please download to get full document.

View again

of 17
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

Food & Beverages

Published:

Views: 4 | Pages: 17

Extension: PDF | Download: 0

Share
Related documents
Description
An Oracle White Paper September 2009 Java Developers Perspective on Oracle Database 11g Introduction The Oracle database furnishes the following technologies for Java developers: JDBC drivers, embedded
Transcript
An Oracle White Paper September 2009 Java Developers Perspective on Oracle Database 11g Introduction The Oracle database furnishes the following technologies for Java developers: JDBC drivers, embedded Java runtime in the database (a.k.a. OracleJVM), SQLJ pre-compiler and runtime, and the JPublisher utility. What s in Oracle Database 11g Release 1 and Release 2 for Java developers? Are you looking at application portability, ease-of-development (productivity), performance, security, reliability or ease of deployment? Focusing only on JDBC and the embedded Java runtime, this paper will first highlight Oracle database support for Java standards, then describe database features that bring development-time productivity, security, and performance to Java developer; finally the paper will describe database features that bring deployment-time performance, scalability, highly-availability and manageability to Java applications. Portability: Java Standards Support Application portability across platforms and vendors is the primary motivation for using Java. Oracle Database 11g Release 1 and Release 2 support Java standards primarily through JDBC and the Java runtime in the database. JDBC 4.0 Support The Oracle database 11g JDBC comes in two flavors: ojdbc5.jar for Java 5 (i.e., JDK 1.5) and ojdbc6.jar for Java 6 (i.e., JDK 1.6). The ojdbc6.jar supports the new JDBC 4.0 specification (dependency on JDK 1.6). Since the specification is publicly available 1, a complete description of JDBC 4.0 is beyond the scope of this paper however, here are the key features: Connection and Statement Enhancements The following enhancements are made to Connection and Statement interfaces: a) Validate a connection boolean isvalid (int timeout): this method returns TRUE if the connection has not been closed and is still valid. b) Set/Get user-defined information and properties using SetClientInfo() and GetClientInfo() methods void setclientinfo(java.lang.string name, java.lang.string value) java.lang.string getclientinfo(java.lang.string name) java.util.properties getclientinfoproperties() 1 c) Setting a statement poolable void setpoolable(boolean poolable) d) Check whether a Statement object is poolable or not boolean ispoolable() e) New Statement interface and class StatementEventListener interface on PooledConnection; and StatementEvent class Wrapper Interface The Wrapper interface allows accessing vendor extensions to the following JDBC interfaces: java.sql.connection, java.sql.databasemetadata, java.sql.parametermetadata, java.sql.resultset, java.sql.resultsetmetadata, java.sql.statement, javax.sql.datasource. The Wrapper interface defines an unwrap() method which takes an interface as an argument and returns an object (or a proxy for the object) that implements the given interface. The returned object is used to access the methods not exposed by the proxy. The iswrapperfor() method returns true if the calling object implements the interface argument. If iswrapperfor() returns true then calling unwrap() with the same argument should succeed. New Standard Datatypes java.sql.rowid a standard Java type for mapping SQL ROWID Methods: java.sql.rowid xrowid = rs.getrowid(1); ps.setrowid(1, xrowid); java.sql.sqlxml 2 : a standard and driver-independant Java type for mapping of SQL XMLType datatype methods SQLXML createsqlxml() throws SQLException; public XMLStreamReader getxmlstreamreader() public XMLStreamWriter putxmlstreamwriter() public void setstring(string text) SQL 2003 National Character Set types including: NCHAR, NCLOB: say goodbye to setformofuse; NVARCHAR and LONGNVARCHAR. LOB Enhancements The Connection interface has been enhanced with createblob, createclob, and createnclob methods for creating empty Blob, Clob, and Nclob objects: Blob ablob = con.createblob(); The newly created Blob, ablob contains no data; the setxxx() methods can be invoked on the CLOB interface to populate it: 2 Currently not yet available int numwritten = ablob.setbytes(1, val); Conversely, getblob(), getclob(), getncolb() methods can be used for retrieving the LOB value from a ResultSet: Blob blob = rs.getblob(1); Exception Hierarchy JDBC 4.0 furnishes a complete rework of exception framework with: a) Support for Java SE For-each Loops: SQLException now implements java.lang.iterable throwable allowing easy navigation of SQLExceptions b) Support for Java SE Chained Exceptions: SQLExceptions may have one or more causal relationships c) New SQLException Subclasses: SQLTransientException, and SQLNonTransientException RowSet (JSR-114) Enhancements JDBC 4.0 brings minor enhancements to the RowSet API such as getters and setters for NChar and RowId OracleJVM Compliance with Java 5 The embedded Java VM in the database (a.k.a. OracleJVM) allows running Java SE applications and libraries directly in the Oracle database resulting in significant productivity and performance gains. Oracle database 11g releases support Java SE 5 (i.e., compatibility with JDK 1.5) and in addition, the RowSet (JSR-114) in server-side JDBC, and JMX for managing the session JVM. Generic Database Features for Application Development Beyond Java standards, Oracle Database 11g Release 1 and Release 2 expose generic database capabilities aiming at improving Java applications development. Features available through JDBC include: SYS.ANYDATA and SYS.ANYTYPE data types, LOB prefetching, SecureFiles LOBs, Client & Server Query Result cache, Query change notification. Features available through the embedded Java runtime include: like-jdk interface, output redirect, property interface, database resident JAR, and two-tier duration of Java session state. SYS.ANYDATA and SYS.ANYTYPE The SQL SYS.ANYDATA is a polymorph data type which, at a given time, contains an instance of a specific type description along with data. Over time, a SYS: ANYDATA column may contain any SQL type (i.e., VARCHAR, a NUMBER, a TIMESTAMP, FLOAT, etc). Furthermore, it can be persisted. The SYS.ANYTYPE SQL type contains the type description of any SQL type (including objects types and collections) that can be transient or persistent, named or unnamed. It maps to oracle.sql.typedescriptor class. Client Query Result Cache Oracle Database 11g Release 2 furnish Table Annotation for caching query results sets in client memory (JDBC-OCI driver only) and synchronized with database changes as if the query was being continuously executed. ALTER TABLE sales RESULT_CACHE (MODE FORCE); When a table is annotated as cache worthy all queries run against the table become candidates for caching in the client/server cache. This eliminates the need for changing the application to add query level hints. Retrieval of results set locally from the client memory is much faster than re-processing the query, and retrieving results from the disk; frequently executed queries experience a significant performance improvement when their results are cached. Internal testing of a standard benchmark shows response time improvements of up to 22% and a 6 times reduction in server CPU consumption. Oracle Database 11g Release 1 only furnishes Client Query Result Cache with query annotation i.e., using the /* + result_cache */ hint. select /*+ result_cache */ * from employees Server Query Result Cache Results of queries can also be cached on the database side (within the shared pool). Users can annotate a query with the /* + result_cache */ hint as in CQRC (see previous feature above) to indicate that result sets are to be cached. Being on the database side, Server Query Result Cache is available to all database users irrespective of the language ad API however, unlike CQRC, it requires a database roundtrip. The RESULT_CACHE_MODE initialization parameter controls whether the server query result cache is used for all queries (when possible), or only for annotated queries. Prefetch in 1st Roundtrip Saving Millions of Database Roundtrips per Day For ad-hoc SQL queries, the new pre-fetch mechanism combines parse, execute, and fetch to retrieves the first batch of the results set in the first interaction with the database. Internal reliable testing shows 50% reduction in network roundtrip; 50% reduction in response time; 30% reduction of server and client CPU consumption. To put this reduction in perspective, a typical web retail application issuing 1 million ad-hoc queries per day (or a determined period of time) will see a reduction of 1 million roundtrips during the same period. LOB Prefetching To improve query performance of smaller LOBs, LOB data and length can be prefetched and cached while also fetching the locator. SecureFiles LOB SecureFiles (LOBs with STORE as SECUREFILE option), reduce the storage requirements for LOB data and increase performance in accessing it. Multiple SQL parameters control SecureFiles LOBS. DEDUPLICATE in CREATE TABLE and ALTER TABLE statements enables the application to specify that LOB data that are identical in two or more rows in LOB column will all share the same data block, thus saving disk space COMPRESS turns on LOB compression. ENCRYPT turns on LOB encryption and optionally selects an encryption algorithm. Each SecureFiles LOB column can have its own encryption specification, independent of the encryption of other columns (LOB or non-lob). Oracle JDBC supports SecureFiles LOB though new APIs including: oracle.sql.{blobregion/clobregion} java.sql.{clobshare/blobshare} oracle.sql.{setoptions/getoptions} oracle.sql.{blob/clob}.{setsharedregions/getsharedregions} oracle.sql.{clob/blob}.fragment{insert/delete/move/replace} oracle.sql.{clob/blob}.{open/copy/getchunksize} Zero-Copy SecureFiles LOB Zero-copy consists in bypassing the copy of LOB data into internal buffer on the server-side; as a result SecureFiles LOB operations are fater. setupsecurefile(); Blob.getBytes(); Net Services: IPv6 Standard Support IPv6 is the next generation IP protocol, designed to replace IPv4. As of Oracle Database 11g Release 2, Oracle furnishes a complete IPv6 support for single-instance databases running on dual-stack or IPv6-only host. The IP session layer has been abstracted to enable the listener to support IPv6 and IPv4 interfaces during the transition phases. A JDBC URL using IPv6 adress will look like the following: (HOST=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210])(PORT=5521)) (CONNECT_DATA=(SERVICE_NAME=sales.acme.com)) Net Services: Fast Connect Time Failover and Retry Faster failover can be achieved at connection establishment time by the use of new Net Services parameters. Rather than waiting for system level TCP timeouts, connect level timeouts can be set in seconds based on network latency. TCP.CONNECT_TIMEOUT enabled by default (60 sec.) One can also set retry count for transparent retries at connection establishment time. RETRY_COUNT (default is 0) See Net Services documentation for more details. Native AQ Protocol A new native AQ protocol (as opposed to a PL/SQL based interface) improves the performance of JMS-over-AQ operations up to 300% and a reduction of server CPU utilization (a consequence of non utilization of PL/SQL interface). Query Change Notification JDBC support for Database and Query Notification is a scalability mechanism, which let s a JDBC thread subscribe to notification of changes in a query result set. Using the feature involves the following steps: (i) Registration: JDBC applications can register SQL queries (i.e., create registrations) using either the JDBC-style of PL/SQL-style registration. (ii) SQL Query Association (Table Changes): associate SQL queries with the registrations. (iii) RDBMS Notification: upon DDL and/or DML changes that impact the registered queries or their result sets, the Oracle database notifies the JDBC thread through a dedicated network connection. The driver transforms these notifications into Java events, received by the application. Middle-tier may use this feature to invalidate and refresh data caches, timely. See more details on the APIs in the Oracle Database 11g JDBC doc. Data Integrity and Encryption in JDBC-Thin The Oracle database supports AES256, AES192, or AES128 encryptions algorithms. To protect data transfer from attacks, such as data modification, deleted packets, and replay attacks, a cryptographic digest, using MD5 or SHA-1 hashing algorithms is included with each message sent across the network. JDBC programs set the encryption and checksum algorithms as connection property; if the database does not accept such encryption or checksum, the connection attempt will fail. sqlnet.ora SQLNET.ENCRYPTION_TYPES_SERVER = (AES256,AES192,AES128) SQLNET.ENCRYPTION_SERVER = accepted jdbc prop.setproperty(oracleconnection.connection_property_thin_net_encryption_level,ano Services.ANO_REQUIRED); prop.setproperty( OracleConnection.CONNECTION_PROPERTY_THIN_NET_ENCRYPTION_TYPES, ( + AnoServices.ENCRYPTION_AES256 + , +AnoServices.ENC RYPTION_AES192 + ) ); Strong Authentication in JDBC-Thin Strong authentication consists in Oracle authentication adapters, which support third-party and industry-standard authentication methods including: Kerberos, Remote Authentication Dial-In User Service (RADIUS), Distributed Computing Environment (DCE), and Secure Sockets Layer (SSL). In this release, JDBC-Thin supports Kerberos, RADIUS and SSL authentications. It works as follow: #1: Configure and starts the third party authentication server (i.e., Radius, Kerberos) or set the keystore. #2: Configure the database to use third party authentication REMOTE_OS_AUTHENT = TRUE (INIT.ORA) SQL create user ssl_client1 identified externally as 'CN=Test Client2,C=US ; SQL grant create session,connect,resource to ssl_client1; #3: Configure Net services for Radius or Kerberos sqlnet.authentication_services = (beq,kerberos5) sqlnet.authentication_kerberos5_service = dbji sqlnet.kerberos5_conf = /home/jdbc/security/kerberos/krb5.conf sqlnet.kerberos5_keytab = /home/jdbc/security/kerberos/dbji.stacv41 sqlnet.kerberos5_conf_mit = true sqlnet.kerberos_cc_name = /tmp/krb5cc_5088 #4: Set connection property in JDBC application prop.setproperty(oracleconnection.connection_property_thin_net_authentication_servi CES, ( +AnoServices.AUTHENTICATION_RADIUS+ ) ); OS Authentication in JDBC The Oracle database 11g allows delegating client authentication to the Operating System. This permits users to authenticate and connect to the database using their OS credentials. #1: Enable OS authentication in init.ora REMOTE_OS_AUTHENT = TRUE #2: Create a database user to allow an OS authenticated connection: CREATE USER ops$w_rose IDENTIFIED EXTERNALLY; GRANT CONNECT TO ops$w_rose; #3: In your JDBC application String url = Driver driver = new oracle.jdbc.oracledriver(); DriverManager.registerDriver(driver); Properties props = new Properties(); Connection conn = DriverManager.getConnection( url, props); Database Features for Application Deployment Manageability is a key requirement in production environment for Java applications running against (i.e., JDBC, Java EE components) or within the Oracle database (i.e., Java in the database). The following manageability features are available through JDBC: Default Service, MBean for Logging, programmatic startup and shutdown. The following manageability features are available through the embedded Java runtime: JIT compiler, Like-JDK interface, Properties interface, JMX, Database Resident JARs, Output redirect, Two-tier duration of Java session state, and OracleJVM Utilities enhancements. OracleJVM JIT Compiler Java in the database has been introduced since 8i, and addresses a specific set of user-defined database functionality more efficiently than PL/SQL and Java EE. However, it has not yet been massively adopted because (i) it s been perceived as slower than the JDK VM for pure java execution (even though the combination of SQL and Java runs faster in the database); (ii) the Native Compiler (a.k.a. NCOMP) which brings significant performance is rarely used due to a poor ease-of-use (i.e., explicit step and requires a C Compiler).. Prior to Oracle Database 11g, there were 3 Java execution modes: (i) Full Interpreted (out-of-the-box), (ii) System NCOMP (JAccelerator installed from the companion CD), and (iii) user NCOMP (full compiled). Most customers run Java fully interpreted mode (both system and user classes). Starting with Oracle Database 11g Release 1, the OracleJVM furnishes a just-in-time compiler (JIT). The JIT dynamically and transparently produces native binaries from any Java classes existing in the database. The binary code are stored, avoiding recompilation. The JIT is enabled by default (out-ofthe-box) and does not need a C compiler or further configuration. In house testing using industry standard benchmark shows an order of magnitude (10 x) speed-up. JDBC Default Service Starting with the XE release, the Oracle database comes with a new connection feature. Under certain conditions, the Oracle database connection adapter requires only the host name of the computer where the database is installed. As a result, parts of the JDBC connection URL syntax become optional: In this URL: // is optional. port is optional; specify a port only if the default Oracle Net listener port (1521) is not used ORCL: default service name is optional; the connection adapter for the Oracle database client connects to the default service on the host, which is set to ORCL in the listener.ora file. The example below shows a basic configuration of the listener.ora file, where the default service is defined. Example 3 2 Default Service Configuration in listener.ora MYLISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=test555)(PORT=1521)) ) DEFAULT_SERVICE_MYLISTENER=dev.testserver.com SID_LIST_MYLISTENER = (SID_LIST= (SID_DESC=(SID_NAME=dbjf)(GLOBAL_ DBNAME=dev.testserver.com)(ORACLE_HOME=/test/oracle)) ) Restart the listener with the following command: lsnrctl start mylistener The following URLs should work with this configuration: )(PORT=1521))) ))) )(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=))) Note: Default service is a new feature starting with Oracle Database 11g Release 1. If you use any older version of the Oracle database client to connect to the database, then you must specify the SID and port number. OracleJVM Like-JDK Interface Oracle Database 11g OJVM provides a command line interface which is similar to JDK/JRE Java shell command. Similar to the JDK virtual machine (VM), this interface lets you run Java code directly from the file system without loading the code into the database. The RUNJAVA command line interface: is analogous to JDK/JRE Java shell command Uses the standard -classpath syntax to indicate where to find the classes to load Can set the system properties using the JDK standard -D syntax Implemented by the following functions: FUNCTION runjava(cmdline VARCHAR2)RETURN VARCHAR2; FUNCTION runjava_in_current_session(cmdline VARCHAR2) RETURN VARCHAR2; The command line interface is a PL/SQL function that takes a string (VARCHAR2) argument and parses it as a command line input. If the input is properly formed, the interface runs the indicated Java method in the OracleJVM. The PL/SQL package DBMS_JAVA provides the runjava function It takes the Java command line as its only argument and runs it in the OracleJVM; the format of the command line is the same as that taken by the JDK shell command [option switches] name_of_class_to_execute [arg1 arg2... argn] The switches are : -classpath, -D, -Xbootclasspath, and -jar. In addition, the RUNJAVA command line has been integrated with OJVMJAVA as illustrated by the following command: ojvmjava -u scott/tiger -runjava -d edidrp7p1:1521:orcl t $ java -cp. Workers 621 Director Properties Interface In any Java runtime, the java.lang.system class contains a table associating certain String keys to String values known as the System.properties. The values in this table are used in Java session initialization before execution of any user code. In releases
Recommended
View more...
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x