SlideShare a Scribd company logo
Writing Java Stored Procedures
with Oracle RDBMS
Martin Toshev
Who am I
Software consultant (CoffeeCupConsulting)
BG JUG board member (http://jug.bg)
OpenJDK and Oracle RDBMS enthusiast
Twitter: @martin_fmi
Writing Stored Procedures in Oracle RDBMS
Work in progress …
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 (20)

Advanced Java
Advanced JavaAdvanced Java
Advanced Java
Hossein Mobasher
 
WebLogic Scripting Tool Overview
WebLogic Scripting Tool OverviewWebLogic Scripting Tool Overview
WebLogic Scripting Tool Overview
James Bayer
 
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin ToshevJavantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin Toshev
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
Ryan Cuprak
 
Java programming and security
Java programming and securityJava programming and security
Java programming and security
UmeshchandraYadav5
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
Dan Stine
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolution
Atul Sehdev
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Designing a play framework application
Designing a play framework applicationDesigning a play framework application
Designing a play framework application
VulcanMinds
 
12 Things About WebLogic 12.1.3 #oow2014 #otnla15
12 Things About WebLogic 12.1.3 #oow2014 #otnla1512 Things About WebLogic 12.1.3 #oow2014 #otnla15
12 Things About WebLogic 12.1.3 #oow2014 #otnla15
Frank Munz
 
Tech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM WorkflowsTech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM Workflows
51 lecture
 
Oracle WebLogic Server: Remote Monitoring and Management
Oracle WebLogic Server: Remote Monitoring and ManagementOracle WebLogic Server: Remote Monitoring and Management
Oracle WebLogic Server: Remote Monitoring and Management
Revelation Technologies
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c Administration
Revelation Technologies
 
Eureka moment
Eureka momentEureka moment
Eureka moment
Paul Withers
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
Bruno Borges
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
Kevin Webber
 
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
 
Eureka moment
Eureka momentEureka moment
Eureka moment
Paul Withers
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java programPj01 2-install java and write first java program
Pj01 2-install java and write first java program
SasidharaRaoMarrapu
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
Ulrich Krause
 
WebLogic Scripting Tool Overview
WebLogic Scripting Tool OverviewWebLogic Scripting Tool Overview
WebLogic Scripting Tool Overview
James Bayer
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
Dan Stine
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolution
Atul Sehdev
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Designing a play framework application
Designing a play framework applicationDesigning a play framework application
Designing a play framework application
VulcanMinds
 
12 Things About WebLogic 12.1.3 #oow2014 #otnla15
12 Things About WebLogic 12.1.3 #oow2014 #otnla1512 Things About WebLogic 12.1.3 #oow2014 #otnla15
12 Things About WebLogic 12.1.3 #oow2014 #otnla15
Frank Munz
 
Tech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM WorkflowsTech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM Workflows
51 lecture
 
Oracle WebLogic Server: Remote Monitoring and Management
Oracle WebLogic Server: Remote Monitoring and ManagementOracle WebLogic Server: Remote Monitoring and Management
Oracle WebLogic Server: Remote Monitoring and Management
Revelation Technologies
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c Administration
Revelation Technologies
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
Bruno Borges
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
Kevin Webber
 
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
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java programPj01 2-install java and write first java program
Pj01 2-install java and write first java program
SasidharaRaoMarrapu
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
Ulrich Krause
 

Viewers also liked (19)

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 Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java PlatformSecurity Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
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
 
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
 
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
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
Martin Toshev
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
jain.pralabh
 
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
 
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Jitendra Bafna
 
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
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
shekhar1991
 
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
 
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 Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java PlatformSecurity Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
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
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: Intro
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
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
jain.pralabh
 
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
 
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
Jitendra Bafna
 
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
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
shekhar1991
 
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 in Oracle RDBMS (20)

13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
Graham Royce
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
Jayaprasanna4
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
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
 
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
 
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
Д. Ганаа
 
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
 
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.
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
snopteck
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
snopteck
 
Weblogic 101 for dba
Weblogic  101 for dbaWeblogic  101 for dba
Weblogic 101 for dba
Osama Mustafa
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
Hemo Chella
 
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
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
Middleware Training
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
Pooja Talreja
 
Advance java1.1
Advance java1.1Advance java1.1
Advance java1.1
Prince Soni
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
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
 
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
Д. Ганаа
 
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
 
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.
 
Weblogic 101 for dba
Weblogic  101 for dbaWeblogic  101 for dba
Weblogic 101 for dba
Osama Mustafa
 
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
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
Pooja Talreja
 
Ad

More from Martin Toshev (10)

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
 
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)

2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
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
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
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
 
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
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
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
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#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
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
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
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
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
 
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
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
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
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#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 in Oracle RDBMS

  • 1. Writing Java Stored Procedures with Oracle RDBMS Martin Toshev
  • 2. Who am I Software consultant (CoffeeCupConsulting) BG JUG board member (http://jug.bg) OpenJDK and Oracle RDBMS enthusiast Twitter: @martin_fmi
  • 5. Agenda • PL/SQL vs Java Stored Procedures • Writing Java Stored Procedures • Managing Java Stored Procedures • New features in Oracle Database 12c
  • 6. PL/SQL vs Java Stored Procedures
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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)
  • 11. 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
  • 12. 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
  • 13. Writing Java Stored Procedures
  • 14. 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
  • 15. Writing Java Stored Procedures • The loadjava utility uses the CREATE JAVA {SOURCE | CLASS | RESOURCE} command to load source/class/resource files
  • 16. 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
  • 17. 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';
  • 18. Writing Java Stored Procedures • Invoke the func function: VARIABLE result VARCHAR2(20); CALL func() INTO :result PRINT result;
  • 19. 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;
  • 20. Writing Java Stored Procedures demo
  • 21. Managing Java Stored Procedures
  • 22. 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)
  • 23. 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
  • 24. 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);
  • 25. 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)
  • 26. Managing Java Stored Procedures demo
  • 27. New Features in Oracle Database 12c
  • 28. 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)
  • 29. New features in Oracle Database 12c • Native Oracle JVM support for JNDI • Customizing the default java.security resource
  • 30. 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

  • #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)
  • #12: The call memory is further divided into an old and new space
  • #13: 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)
  • #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
  • #19: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #20: You can also specify a different schema (e.g. SAMPLE) using the –schema parameter. For example: loadjava -u orcl -schema SAMPPLE Sample.java
  • #25: 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
  • #26: 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 …