Java stored procedure code Excerpt from Oracle Database

Source: Internet
Author: User

Java stored procedures in Oracle databases can use JMSL to call actual AQ operations. We can use the four frequently used steps below to implement this mode. To create and start the JMS Queue, We can embed the following operations into the SQL script ):

 
 
  1. execute dbms_aqadm.create_queue_table(queue_table => 
    ''queue1'', queue_payload_type => ''SYS.AQ$_JMS_TEXT_MESSAGE'', 
    comment => ''a test queue'', multiple_consumers => false, 
    compatible => ''8.1.0''); 
    execute dbms_aqadm.create_queue
    ( queue_name => ''queue1'', queue_table => ''queue1'' ); 
    execute dbms_aqadm.start_queue(queue_name => ''queue1''); 

The following is an excerpt from the code used to create a Java stored procedure ):

 
 
  1. public static void runTest(String msgBody) 
    { try { // get database connection ora_drv = new OracleDriver(); 
    db_conn = ora_drv.defaultConnection(); 
    // setup sender (cf online code sample) .. 
    // create message s_msg = s_session.createTextMessage(msgBody); 
    // send message sender.send(s_msg); s_session.commit(); 
    // receive message r_msg = (TextMessage) receiver.receive(); 
    r_session.commit(); 
    // output message text String body = r_msg.getText(); 
    System.out.println("message was ''"+body+"''"); ..} } 

Create Call Spec:

 
 
  1. create or replace procedure jmsproc 
    (t1 IN VARCHAR) as language java name 
    ''jmsSample.main (java.lang.String[])''; / 

Call the stored procedure:

 
 
  1. call jmsproc(''hello'');  

The Web Publishing buffer assisted by the Oracle database is invalid)

A common problem that application structures must face is that database information is reliably cached to improve the performance of the entire system. JCACHE is the standard specification JSR 107 to be published soon. It can solve this problem. It illustrates a method for temporarily caching Java objects in the memory, including object creation, shared access, spooling off-line, failure, and JVM consistency.

It can be used to cache the most frequently read data in JSP, such as the product catalog and price list. Using JCACHE, the response time of most queries will be accelerated by cache data. Internal tests show that the response time is about 15 times faster ).

To track all changes to the original data and refresh the cached data, the Java stored procedure is attached to a table as a trigger. Any changes to this table will automatically call the stored procedure. The latter calls up a defined JSP to invalidate the JCACHE object and maps its status to the Oracle database table.

When it fails, the query that follows it will force the cache to update based on the database data. The following steps read more about Java Stored Procedures this article is taken from the White Paper "release the energy of Java Stored Procedures Unleash the Power of Java Stored Procedures)", you can find this White Paper in the following locations:

 
 
  1. otn.oracle.com/tech/java/java_db/pdf/  
  2. OW_30820_JAVA_STORED_PROC_paper.PDF 

New PL/SQL features in Oracle9i Database 2nd

 
 
  1. otn.oracle.com/tech/pl_sql/pdf/  
  2. Paper_30720_Doc.pdf  
  3. Resolver Spec  
  4. otn.oracle.com/docs/products/oracle9i/  
  5. doc_library/release2/java.920/a96659.pdf  
  6. OracleJVM and Java 2 Security  
  7. otn.oracle.com/docs/products/oracle9i/  
  8. doc_library/release2/java.920/a96656.pdf  

The above content describes the actual operations that can be performed to call AQ using JMSL for Java stored procedures in Oracle databases. We hope this will help you in this regard.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.