The main contents include: Java Development, Package Java program into jar file, upload jar file to Oracle system, Oracle import JAR file in Java class to database, Oracle create function according to import Java class, Oracle operation function.
Software used: Oracle database, Oracle database installed on Linux operating system; Java is developed with idea; uploading jar files with WINSCP; operating Oracle database with PL/SQL;
Java class authoring rules for 1.Oracle operations
Oracle supports different JDK versions, Oracle8 supports JDK1.2,ORACLE9 support JDK1.3,ORACLE10 support JDK1.4,ORACLE11 support JDK1.5
Use this chapter to manipulate Java methods only support static methods, non-static methods are not available
2.IDEA changing the compilation JDK version method
When idea opens, choose File-project Structure
When idea opens, select File-settings
3.IDEA Dozen Jar Bags
Open idea and choose File-project Structure
Open idea
4. Upload the jar package
Open WinSCP, upload the jar file to the Temptest folder in the root directory
5.Oracle Database Operations Jar Package
Enter your Oracle account password and select Connect as Sysdba
Post-Login interface
Select File-New command line
Import jar to Oracle command:
Call Dbms_java.loadjava ('-v-r public-synonym/temptest/oracle-code.jar ');
Prompt error, query reason is imported jar package not all classes are imported successfully, some classes may fail to import. However, most classes are imported successfully. I have tested that importing all the classes succeeds or will report this error.
Query the imported class command:
Select * from where object_type='JAVA CLASS'andobject_name like '%com%'andTIMESTAMP>' 2017-12-21:16:22:42';
6.Oracle creating functions from imported Java code
Run Command :
Test the Created function
To run a function operation on a field in an Oracle table
Oracle calls Java code