SlideShare a Scribd company logo
Writing Java Stored Procedures
with Oracle Database 12c
Martin Toshev
Who am I
Software consultant (self-employed)
BG JUG governance board member (http://jug.bg)
OpenJDK contributor
Agenda
• PL/SQL vs Java Stored Procedures
• Writing Java Stored Procedures
• Managing Java Stored Procedures
• New features in Oracle Database 12c
PL/SQL vs Java Stored Procedures
PL/SQL vs Java Stored Procedures
• Both PL/SQL and Java stored procedures are
executed directly on the RDBMS
• Both PL/SQL and Java stored procedures can be
recompiled dynamically when source code
changes
• Easier migration of Java stored procedures
to/from the application tier
PL/SQL vs Java Stored Procedures
• The PL/SQL Virtual Machine (PVM) is the
database component that executes the PL/SQL
bytecode (lower lever representation of the
PL/SQL code that is generated from the PL/SQL
compiler)
• PVM is written in C
PL/SQL vs Java Stored Procedures
• Java procedures are executed from a JVM (Java
Virtual Machine) process running inside the
Oracle RDBMS:
Oracle
DB
Oracle
RDBMS
PL/SQL JVM
Java
method
PL/SQL vs Java Stored Procedures
• Since the Oracle JVM is embedded in the
database this introduces a number of new
concepts:
– Oracle JVM process that runs within an Oracle database session
– classloader that loads classes from the database
– no notion of main() method
– loading of system classes from the SYS schema (where they are stored)
PL/SQL vs Java Stored Procedures
• Since the Oracle JVM is embedded in the
database this introduces a number of new
concepts:
– oracle.aurora.rdbms.DbmsJava.classForNameAndSchema() for
loading a class from a database schema
– The Oracle JVM uses the database memory structures to store data
– The garbage collector makes use of the call and session memory on a
per-user basis
PL/SQL vs Java Stored Procedures
• Since the Oracle JVM is embedded in the
database this introduces a number of new
concepts:
– no support for JNI
– server-side JDBC driver providing access to Oracle data (using the
"jdbc:default:connection:“ connection URL)
– server-side SQLJ translator – allows embedding of SQL statements in
Java stored procedures
Writing Java Stored Procedures
Writing Java Stored Procedures
• In order to create a Java stored procedure:
o write the Java class that contains the Java
procedure(s) (static method(s) in the class)
o load the compiled Java procedure in the Oracle
database using the loadjava utility or the CREATE
JAVA command
o map a PL/SQL function/procedure to the Java
procedure using the CREATE
FUNCTION/PROCEDURE command
Writing Java Stored Procedures
• The loadjava utility uses the
CREATE JAVA {SOURCE | CLASS |
RESOURCE}
command to load source/class/resource files
Writing Java Stored Procedures
• Example: loading the Sample.java source file
using the orcl user:
• Example: loading the Sample.java source file
using the orcl user and compiling it:
loadjava -u orcl Sample.java
loadjava -u orcl –resolve Sample.java
Writing Java Stored Procedures
• Map the Java static function func() from the
Sample class:
CREATE OR REPLACE FUNCTION func
RETURN VARCHAR2 AS
LANGUAGE JAVA NAME
‘Sample.func() return java.lang.String';
Writing Java Stored Procedures
• Invoke the func function:
VARIABLE result VARCHAR2(20);
CALL func() INTO :result
PRINT result;
Writing Java Stored Procedures
• You can provide privileges for other users to
invoke your class(es) using the loadjava utility or
the GRANT command:
loadjava -grant usr –u orcl Sample.java
GRANT EXECUTE ON Sample TO usr;
Writing Java Stored Procedures
demo
Managing Java Stored Procedures
Managing Java Stored Procedures
• USER_OBJECTS table (OBJECT_TYPE
columns is any of JAVA SOURCE,
JAVA CLASS or JAVA RESOURCE in a
valid/invalid state)
Managing Java Stored Procedures
• JMX can be used to monitor the Oracle JVM
• The current user must be granted the
JMXSERVER role
• The dbms_java.start_jmx_agent can
be used to start the JMX server for the session
Managing Java Stored Procedures
• Java stored procedures can be debugged be
debugged by a JWDP-compliant debugger
• Such as a debugger is provided by jdb and the
JDeveloper IDE
exec DBMS_DEBUG_JDWP.CONNECT_TCP('localhost', 6666);
Managing Java Stored Procedures
• Compiler options can be specified:
– in the JAVA$OPTIONS table
– via the loadjava utility
– via the DBMS_JAVA package (that
creates/modifies the JAVA$OPTIONS table)
Managing Java Stored Procedures
demo
New Features in Oracle Database 12c
New features in Oracle Database 12c
• Support for multiple JDK versions (JDK 6 by
default but JDK 7 or earlier can be specified)
• Considering multitenant databases introduced in
12c: PDBs (pluggable databases) share the same
JDK version specified over the CDB (container
database)
New features in Oracle Database 12c
• Native Oracle JVM support for JNDI
• Customizing the default java.security
resource
New features in Oracle Database 12c
• Enhanced support for logging properties lookup
• Secure use of Runtime.exec
• Improved debugging support for Java Stored
Procedures (watchpoints/breakpoints)
Thank you !
Q&A
Ad

More Related Content

What's hot (19)

Session 41 - Struts 2 Introduction
Session 41 - Struts 2 IntroductionSession 41 - Struts 2 Introduction
Session 41 - Struts 2 Introduction
PawanMM
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Red Hat Developers
 
WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
James Bayer
 
weblogic perfomence tuning
weblogic perfomence tuningweblogic perfomence tuning
weblogic perfomence tuning
prathap kumar
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
Manav Prasad
 
EAP6 performance Tuning
EAP6 performance TuningEAP6 performance Tuning
EAP6 performance Tuning
Praveen Adupa
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOP
PawanMM
 
Weblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencastWeblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencast
Rajiv Gupta
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
Andrei Solntsev
 
Oracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration IOracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration I
Sachin Kumar
 
Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
Som Prakash Rai
 
JavaOne 2011 Recap
JavaOne 2011 RecapJavaOne 2011 Recap
JavaOne 2011 Recap
Jim Bethancourt
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPages
Ulrich Krause
 
Weblogic application server
Weblogic application serverWeblogic application server
Weblogic application server
Anuj Tomar
 
Database change management with Liquibase
Database change management with LiquibaseDatabase change management with Liquibase
Database change management with Liquibase
Jarosław Szczepankiewicz
 
Eureka moment
Eureka momentEureka moment
Eureka moment
Paul Withers
 
Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)
David Chou
 
Session 42 - Struts 2 Hibernate Integration
Session 42 - Struts 2 Hibernate IntegrationSession 42 - Struts 2 Hibernate Integration
Session 42 - Struts 2 Hibernate Integration
PawanMM
 
Life in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPagesLife in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPages
Ulrich Krause
 
Session 41 - Struts 2 Introduction
Session 41 - Struts 2 IntroductionSession 41 - Struts 2 Introduction
Session 41 - Struts 2 Introduction
PawanMM
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Red Hat Developers
 
WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
James Bayer
 
weblogic perfomence tuning
weblogic perfomence tuningweblogic perfomence tuning
weblogic perfomence tuning
prathap kumar
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
Manav Prasad
 
EAP6 performance Tuning
EAP6 performance TuningEAP6 performance Tuning
EAP6 performance Tuning
Praveen Adupa
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOP
PawanMM
 
Weblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencastWeblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencast
Rajiv Gupta
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
Andrei Solntsev
 
Oracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration IOracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration I
Sachin Kumar
 
Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
Som Prakash Rai
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPages
Ulrich Krause
 
Weblogic application server
Weblogic application serverWeblogic application server
Weblogic application server
Anuj Tomar
 
Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)Java on Windows Azure (Cloud Computing Expo 2010)
Java on Windows Azure (Cloud Computing Expo 2010)
David Chou
 
Session 42 - Struts 2 Hibernate Integration
Session 42 - Struts 2 Hibernate IntegrationSession 42 - Struts 2 Hibernate Integration
Session 42 - Struts 2 Hibernate Integration
PawanMM
 
Life in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPagesLife in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPages
Ulrich Krause
 

Viewers also liked (17)

Java ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL DevelopersJava ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL Developers
Lucas Jellema
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
Security Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java PlatformSecurity Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
Modular Java
Modular JavaModular Java
Modular Java
Martin Toshev
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: Intro
Martin Toshev
 
Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
KDB database (EPAM tech talks, Sofia, April, 2015)
KDB database (EPAM tech talks, Sofia, April, 2015)KDB database (EPAM tech talks, Sofia, April, 2015)
KDB database (EPAM tech talks, Sofia, April, 2015)
Martin Toshev
 
Security Architecture of the Java platform
Security Architecture of the Java platformSecurity Architecture of the Java platform
Security Architecture of the Java platform
Martin Toshev
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
Martin Toshev
 
Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in development
Martin Toshev
 
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Martin Toshev
 
The RabbitMQ Message Broker
The RabbitMQ Message BrokerThe RabbitMQ Message Broker
The RabbitMQ Message Broker
Martin Toshev
 
Oracle Database 12c Attack Vectors
Oracle Database 12c Attack VectorsOracle Database 12c Attack Vectors
Oracle Database 12c Attack Vectors
Martin Toshev
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
Simon Ritter
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
Trisha Gee
 
Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Java ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL DevelopersJava ain't scary - introducing Java to PL/SQL Developers
Java ain't scary - introducing Java to PL/SQL Developers
Lucas Jellema
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
Security Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java PlatformSecurity Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: Intro
Martin Toshev
 
KDB database (EPAM tech talks, Sofia, April, 2015)
KDB database (EPAM tech talks, Sofia, April, 2015)KDB database (EPAM tech talks, Sofia, April, 2015)
KDB database (EPAM tech talks, Sofia, April, 2015)
Martin Toshev
 
Security Architecture of the Java platform
Security Architecture of the Java platformSecurity Architecture of the Java platform
Security Architecture of the Java platform
Martin Toshev
 
Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in development
Martin Toshev
 
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Martin Toshev
 
The RabbitMQ Message Broker
The RabbitMQ Message BrokerThe RabbitMQ Message Broker
The RabbitMQ Message Broker
Martin Toshev
 
Oracle Database 12c Attack Vectors
Oracle Database 12c Attack VectorsOracle Database 12c Attack Vectors
Oracle Database 12c Attack Vectors
Martin Toshev
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
Simon Ritter
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
Trisha Gee
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Ad

Similar to Writing Stored Procedures with Oracle Database 12c (20)

13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
Graham Royce
 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part I
SivaSankari36
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
Jayaprasanna4
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Vadym Kazulkin
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
KalsoomTahir2
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
Arun Gupta
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
Docker, Inc.
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1
Д. Ганаа
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
jucaab
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptxJAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
snopteck
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
snopteck
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
Ryan Cuprak
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
Aren Zomorodian
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
London Microservices
 
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdfSAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
VamsiChowdary62
 
Weblogic 101 for dba
Weblogic  101 for dbaWeblogic  101 for dba
Weblogic 101 for dba
Osama Mustafa
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
dhananajay95
 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part I
SivaSankari36
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Vadym Kazulkin
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
KalsoomTahir2
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
Arun Gupta
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
Docker, Inc.
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1
Д. Ганаа
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
jucaab
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
Ryan Cuprak
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
London Microservices
 
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdfSAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
SAP S4 HANA_JAVA Architecture_sys Admin_Day 4.pdf
VamsiChowdary62
 
Weblogic 101 for dba
Weblogic  101 for dbaWeblogic  101 for dba
Weblogic 101 for dba
Osama Mustafa
 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
dhananajay95
 
Ad

More from Martin Toshev (11)

Building highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache SparkBuilding highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache Spark
Martin Toshev
 
Big data processing with Apache Spark and Oracle Database
Big data processing with Apache Spark and Oracle DatabaseBig data processing with Apache Spark and Oracle Database
Big data processing with Apache Spark and Oracle Database
Martin Toshev
 
Jdk 10 sneak peek
Jdk 10 sneak peekJdk 10 sneak peek
Jdk 10 sneak peek
Martin Toshev
 
Semantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12cSemantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12c
Martin Toshev
 
Practical security In a modular world
Practical security In a modular worldPractical security In a modular world
Practical security In a modular world
Martin Toshev
 
Java 9 Security Enhancements in Practice
Java 9 Security Enhancements in PracticeJava 9 Security Enhancements in Practice
Java 9 Security Enhancements in Practice
Martin Toshev
 
Java 9 sneak peek
Java 9 sneak peekJava 9 sneak peek
Java 9 sneak peek
Martin Toshev
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8
Martin Toshev
 
java2days 2014: Attacking JavaEE Application Servers
java2days 2014: Attacking JavaEE Application Serversjava2days 2014: Attacking JavaEE Application Servers
java2days 2014: Attacking JavaEE Application Servers
Martin Toshev
 
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Martin Toshev
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 
Building highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache SparkBuilding highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache Spark
Martin Toshev
 
Big data processing with Apache Spark and Oracle Database
Big data processing with Apache Spark and Oracle DatabaseBig data processing with Apache Spark and Oracle Database
Big data processing with Apache Spark and Oracle Database
Martin Toshev
 
Semantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12cSemantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12c
Martin Toshev
 
Practical security In a modular world
Practical security In a modular worldPractical security In a modular world
Practical security In a modular world
Martin Toshev
 
Java 9 Security Enhancements in Practice
Java 9 Security Enhancements in PracticeJava 9 Security Enhancements in Practice
Java 9 Security Enhancements in Practice
Martin Toshev
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8
Martin Toshev
 
java2days 2014: Attacking JavaEE Application Servers
java2days 2014: Attacking JavaEE Application Serversjava2days 2014: Attacking JavaEE Application Servers
java2days 2014: Attacking JavaEE Application Servers
Martin Toshev
 
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Martin Toshev
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Top 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing ServicesTop 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing Services
Infrassist Technologies Pvt. Ltd.
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 

Writing Stored Procedures with Oracle Database 12c

  • 1. Writing Java Stored Procedures with Oracle Database 12c Martin Toshev
  • 2. Who am I Software consultant (self-employed) BG JUG governance board member (http://jug.bg) OpenJDK contributor
  • 3. Agenda • PL/SQL vs Java Stored Procedures • Writing Java Stored Procedures • Managing Java Stored Procedures • New features in Oracle Database 12c
  • 4. PL/SQL vs Java Stored Procedures
  • 5. PL/SQL vs Java Stored Procedures • Both PL/SQL and Java stored procedures are executed directly on the RDBMS • Both PL/SQL and Java stored procedures can be recompiled dynamically when source code changes • Easier migration of Java stored procedures to/from the application tier
  • 6. PL/SQL vs Java Stored Procedures • The PL/SQL Virtual Machine (PVM) is the database component that executes the PL/SQL bytecode (lower lever representation of the PL/SQL code that is generated from the PL/SQL compiler) • PVM is written in C
  • 7. PL/SQL vs Java Stored Procedures • Java procedures are executed from a JVM (Java Virtual Machine) process running inside the Oracle RDBMS: Oracle DB Oracle RDBMS PL/SQL JVM Java method
  • 8. PL/SQL vs Java Stored Procedures • Since the Oracle JVM is embedded in the database this introduces a number of new concepts: – Oracle JVM process that runs within an Oracle database session – classloader that loads classes from the database – no notion of main() method – loading of system classes from the SYS schema (where they are stored)
  • 9. PL/SQL vs Java Stored Procedures • Since the Oracle JVM is embedded in the database this introduces a number of new concepts: – oracle.aurora.rdbms.DbmsJava.classForNameAndSchema() for loading a class from a database schema – The Oracle JVM uses the database memory structures to store data – The garbage collector makes use of the call and session memory on a per-user basis
  • 10. PL/SQL vs Java Stored Procedures • Since the Oracle JVM is embedded in the database this introduces a number of new concepts: – no support for JNI – server-side JDBC driver providing access to Oracle data (using the "jdbc:default:connection:“ connection URL) – server-side SQLJ translator – allows embedding of SQL statements in Java stored procedures
  • 11. Writing Java Stored Procedures
  • 12. Writing Java Stored Procedures • In order to create a Java stored procedure: o write the Java class that contains the Java procedure(s) (static method(s) in the class) o load the compiled Java procedure in the Oracle database using the loadjava utility or the CREATE JAVA command o map a PL/SQL function/procedure to the Java procedure using the CREATE FUNCTION/PROCEDURE command
  • 13. Writing Java Stored Procedures • The loadjava utility uses the CREATE JAVA {SOURCE | CLASS | RESOURCE} command to load source/class/resource files
  • 14. Writing Java Stored Procedures • Example: loading the Sample.java source file using the orcl user: • Example: loading the Sample.java source file using the orcl user and compiling it: loadjava -u orcl Sample.java loadjava -u orcl –resolve Sample.java
  • 15. Writing Java Stored Procedures • Map the Java static function func() from the Sample class: CREATE OR REPLACE FUNCTION func RETURN VARCHAR2 AS LANGUAGE JAVA NAME ‘Sample.func() return java.lang.String';
  • 16. Writing Java Stored Procedures • Invoke the func function: VARIABLE result VARCHAR2(20); CALL func() INTO :result PRINT result;
  • 17. Writing Java Stored Procedures • You can provide privileges for other users to invoke your class(es) using the loadjava utility or the GRANT command: loadjava -grant usr –u orcl Sample.java GRANT EXECUTE ON Sample TO usr;
  • 18. Writing Java Stored Procedures demo
  • 19. Managing Java Stored Procedures
  • 20. Managing Java Stored Procedures • USER_OBJECTS table (OBJECT_TYPE columns is any of JAVA SOURCE, JAVA CLASS or JAVA RESOURCE in a valid/invalid state)
  • 21. Managing Java Stored Procedures • JMX can be used to monitor the Oracle JVM • The current user must be granted the JMXSERVER role • The dbms_java.start_jmx_agent can be used to start the JMX server for the session
  • 22. Managing Java Stored Procedures • Java stored procedures can be debugged be debugged by a JWDP-compliant debugger • Such as a debugger is provided by jdb and the JDeveloper IDE exec DBMS_DEBUG_JDWP.CONNECT_TCP('localhost', 6666);
  • 23. Managing Java Stored Procedures • Compiler options can be specified: – in the JAVA$OPTIONS table – via the loadjava utility – via the DBMS_JAVA package (that creates/modifies the JAVA$OPTIONS table)
  • 24. Managing Java Stored Procedures demo
  • 25. New Features in Oracle Database 12c
  • 26. New features in Oracle Database 12c • Support for multiple JDK versions (JDK 6 by default but JDK 7 or earlier can be specified) • Considering multitenant databases introduced in 12c: PDBs (pluggable databases) share the same JDK version specified over the CDB (container database)
  • 27. New features in Oracle Database 12c • Native Oracle JVM support for JNDI • Customizing the default java.security resource
  • 28. New features in Oracle Database 12c • Enhanced support for logging properties lookup • Secure use of Runtime.exec • Improved debugging support for Java Stored Procedures (watchpoints/breakpoints)

Editor's Notes

  • #9: The Java process runs within an Oracle database session – this is similar to how a JVM runs in a standalone OS process server-side JDBC driver is tightly integrated with the Oracle database in order to provide fast access to Oracle data - The SQLJ translator translates Java code with SQL and creates the proper Java code that executes the statements out of those SQL statements (using the server side JDBC translator)
  • #10: The call memory is further divided into an old and new space
  • #11: The Java process runs within an Oracle database session – this is similar to how a JVM runs in a standalone OS process server-side JDBC driver is tightly integrated with the Oracle database in order to provide fast access to Oracle data - The SQLJ translator translates Java code with SQL and creates the proper Java code that executes the statements out of those SQL statements (using the server side JDBC translator)
  • #14: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #15: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #16: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #17: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #18: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #23: There are some prerequisites for enabling debugging for a user – the user must be granted the DEBUG ANY PROCEDURE and DEBUG CONNECT SESSION priviliges and assigned to an ACL: begin sys.DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE( host => 'localhost', ace => xs$ace_type(privilege_list => xs$name_list('jdwp'), principal_name => 'c##demo', principal_type => xs_acl.ptype_db)); end; 2) When attaching to an Eclipse IDE debugger the current session crashes
  • #24: There are some prerequisites for enabling debugging for a user – the user must be granted the DEBUG ANY PROCEDURE and DEBUG CONNECT SESSION priviliges and assigned to an ACL: begin sys.DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE( host => 'localhost', ace => xs$ace_type(privilege_list => xs$name_list('jdwp'), principal_name => 'c##demo', principal_type => xs_acl.ptype_db)); end; 2) When attaching to an Eclipse IDE debugger the current session crashes 3) Many people just use plain System.out.println() statements …