Wednesday, July 17, 2013

Aurora - Oracle's Java Virtual Machine

A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java platform.Oracle includes a JVM in its database. The JVM is called Aurora.The Aurora JVM runs in the same process space and address space as the RDBMS kernel, sharing its memory heaps and directly accessing its relational data.



Oracle includes a JVM in its database. The JVM is called Aurora.The Aurora JVM runs in the same process space and address space as the RDBMS kernel, sharing its memory heaps and directly accessing its relational data

In this post, I will briefly describe the Aurora towards oracle documents and give an example approach for using the sqlj option.




Main Components of Aurora JVM:


Library Manager: Loads java source, class files or resource files into the database. Library manager is invoked bye CREATE JAVA {SOURCE | CLASS |RESOURCE} statement.

Memory Manager:Automated storage management is one of Java's key features. In particular, the Java run-time system requires automatic garbage collection (deallocation of memory held by unused objects). The memory manager uses memory allocation techniques tuned to object lifetimes. Objects that survive beyond call boundaries are migrated to appropriate memory areas. Also, the memory manager minimizes the footprint per session by sharing immutable object state such as class definitions and final static variables.

Compiler: It translates Java source files into architecture-neutral instructions called bytecodes. Invoked by the "CREATE JAVA SOURCE" statement.

Interpreter:
 The interpreter and associated Java run-time system execute standard Java class files.

Class Loader: 

Locates, loads, and initializes Java classes stored in the RDBMS. 
resolve external references.
Invokes the Java compiler automatically when Java class files must be recompiled   

Verifier: 
prevents the inadvertent use of "spoofed" Java class files

Server-Side JDBC Driver:
 a specially tuned JDBC driver runs directly inside the RDBMS. It supports Oracle-specific datatypes, NLS character sets, and stored procedure.

Server-Side SQLJ Translator: 
SQLJ enables you to embed SQL statements in Java programs. A highly optimized SQLJ Translator runs directly inside the RDBMS, where it provides run-time access to Oracle data via the server-side JDBC drive. SQLJ forms can include queries, DML, DDL, transaction control statements, and calls to stored procedures

JServer Accelerator:
 It translates standard Java class files into specialized C source files that are processed by a platform-dependent C compiler into native libraries, which the Aurora JVM can load dynamically.

----------------------------------------------------------------------------------------------------------

SQLJ Translator Example:

Following can be considered an example for the SQLJ usage;

Here we create a java source that executes a sql. Note that we use sqlj to embed sql statement into this java program. SQLJ declarations are preceded by the #sql token.

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "TestDba2"
   AS import java.sql.*;
public class TestDba2                                 
{
  public static String DualeYaz ()
    throws SQLException
  {
    String addr;                                    
    #sql { SELECT dummy INTO :addr FROM dual };
    return "TRUE";
  }
};

We create a function to run the java.

create or replace function Duale_Yaz return varchar2
AS LANGUAGE JAVA
NAME 'TestDba2.DualeYaz() return java.lang.String';

We execute the function..

select Duale_Yaz from dual;

No comments :

Post a Comment

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.