How do I avoid re-entrant problems in Oracle JVM

I have a Java program called LanguageFunctions. This Java program has several methods that translate the data within a String or CLOB. I want to use this Java program as a stored procedure, and specifically the methods as Oracle functions. I want this function to be accessed simultaneously without either re-entrant, lock or performance concerns. I want to be able to use the functions something like this:
SELECT TO_CHINESE(VARCHARCOL1) FROM DUAL;
SELECT TO_FINISH(CLOBCOL1) FROM DUAL;
I am having trouble understanding the Java requirements for these methods. I am greatly concerned about multi-user usage and issues with re-entrant code. Does this have to be a static class? If not, how when and where does it get instantiated (I hope not for every invocation of the function)? How to I avoid having one user accidentally changing the data within the method when executed in parallel?
BTW: I have successfully moved these into the Oracle JVM, and executed them as a single user. My main concern is the re-entrant code issues.
Thanks

Thanks for the reply, I meant no disrespect, I was just trying to be a little funny...
I did read that any method that you want to use as an Oracle function must be static. So I understand that as a given. However, the class I am converting uses static Class variables. You can see this in the example as the textOut variable.
When two users are accessing this function in parallel, I could see the following series of events ocurring, and it is my concern. There is only one textOut, and I believe it can be modifed by both functions simultanesouly with unexpected results. I'm assuming my for loop is set to x < 2.
SessionA issues: SELECT TO_DANISH('HELLO') FROM DUAL;
   A --> textOut = ""
   A --> textOut = "HELLO"
   A --> textOut = "HELLOxy"
   A --> textOut = "HELLOxyxy"
SessionB issues: SELECT TO_DANISH('GOODBYE') FROM DUAL;
   B --> textOut = ""
   A --> textOut = "xy"
   B --> textOut = "GOODBYE"
   A --> textOut = "GOODBYExy"
Session A returns: "GOODBYExy"     (expected "HELLOxyxy")
   B --> textOut = "GOODBYExyxy"
   B --> textOut = "GOODBYExyxyxy"
Session B returns: "GOODBYExyxyxy" (expected "GOODBYExyxy")I'm I correct in my assumption that this is an issue? If so, what type of programm architecture would be best to use to manage this? I've tried to provide a simple working example of the issue, but the program that I'm working on actually alters the contents of textOut (as a static Class variable) in 5 or 6 different methods, including one method using recursion. I know I may need to make changes to the program architecture to make it work properly in a multi-user environment as an Oracle function. I'm just a little confused on what the appropriate architecture is. Once again any help is appreciated!
Joel

Similar Messages

  • Oracle Team?? EJBean Problem on Oracle JVM

    Hi,
    I am using Jdeveloper3.1 and Oracle8.1.6 for my application. I could deploy and run the EJB on Oracle JVM without any problems. But when I am trying to connect to the Database it is giving me the null value instead of 'Y' or 'N'. The same EJbean I used as the USEBEAN in JSP and it is giving me correct results. I tried to debug and I found it is not getting the connection.I am giving the example I tried.
    1. EJB
    package EJBSample;
    import java.rmi.RemoteException;
    import javax.ejb.*;
    import java.sql.*;
    public class ValidateBean implements SessionBean {
    String UId;
    String PWd;
    Connection conn;
    Statement st;
    public ValidateBean() {
    public void setUId(String UId) throws RemoteException {
    this.UId=UId;
    public void setPWd(String PWd) throws RemoteException {
    this.PWd=PWd;
    public String getUId() throws RemoteException {
    return UId;
    public String getPWd() throws RemoteException {
    return PWd;
    public String validate() throws RemoteException {
    String flg = null,login = null,pass = null;
    try{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); flg = "Before Conn..."; conn = DriverManager.getConnection("jdbc:oracle:thin:@pcgamingit4:1521:Everest","scott","tiger"); flg = "After Conn..."; st = conn.createStatement(); String str = "select * from CRM_WRK_LCTN where LOGINID='"+UId+"'"; ResultSet rs = st.executeQuery(str);
    while(rs.next()){
    login = (String) rs.getString("LOGINID");
    if(login.equals(UId)){
    pass = (String) rs.getString("PASSWORD");
    break;
    if( (UId.equals(login)) && (PWd.equals(pass)))
    flg="Y";
    else
    flg="N";
    st.close();
    conn.close();
    }catch(Exception e){ }
    return flg;
    public void ejbCreate() throws RemoteException, CreateException {
    public void ejbActivate() throws RemoteException {
    public void ejbPassivate() throws RemoteException {
    public void ejbRemove() throws RemoteException {
    public void setSessionContext(SessionContext ctx) throws RemoteException {
    2. Client:
    package EJBClient;
    import java.sql.*;
    import java.util.*;
    import javax.naming.*;
    import oracle.aurora.jndi.sess_iiop.*;
    public class ValidateClient {
    public static void main(String[] args) {
    String ejbUrl = "sess_iiop://localhost:2481:Everest/test/Validate";
    String username = "scott";
    String password = "tiger";
    // Setup the environment
    Hashtable environment = new Hashtable();
    // Tell JNDI to speak sess_iiop
    environment.put(javax.naming.Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    // Tell sess_iiop who the user is
    environment.put(Context.SECURITY_PRINCIPAL, username);
    // Tell sess_iiop what the password is
    environment.put(Context.SECURITY_CREDENTIALS, password);
    // Tell sess_iiop to use credential authentication
    environment.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
    // Lookup the URL
    EJBSample.ValidateHome homeInterface = null;
    try {
    System.out.println("Creating an initial context");
    Context ic = new InitialContext(environment);
    System.out.println("Looking for the EJB published as 'test/Validate'");
    homeInterface = (EJBSample.ValidateHome) ic.lookup(ejbUrl);
    catch (ActivationException e) {
    System.out.println("Unable to activate : " + e.getMessage());
    e.printStackTrace();
    System.exit(1);
    catch (CommunicationException e) {
    System.out.println("Unable to connect: " + ejbUrl);
    e.printStackTrace();
    System.exit(1);
    catch (NamingException e) {
    System.out.println("Exception occurred!");
    System.out.println("Cause: This may be an unknown URL, or some" +
    " classes required by the EJB are missing from your classpath.");
    System.out.println("Suggestion: Check the components of the URL," +
    " and make sure your project includes a library containing the" +
    " EJB .jar files generated by the deployment utility.");
    e.printStackTrace();
    System.exit(1);
    // That's it!
    try {
    System.out.println("Creating a new EJB instance");
    EJBSample.Validate remoteInterface = homeInterface.create();
    remoteInterface.setUId("mallik");
    remoteInterface.setPWd("malli");
    System.out.println("Calling EJBSample.Validate methods...\n");
    // Method calls go here!
    String str = remoteInterface.validate();
    // e.g.
    // System.out.println(remoteInterface.foo());
    System.out.println("...done!");
    System.out.println(str);
    catch (Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    3. Result:
    EJBClient.ValidateClient
    Creating an initial context
    Looking for the EJB published as 'test/Validate'
    Creating a new EJB instance
    Calling EJBSample.Validate methods...
    ...done!
    Before Conn...
    Can you please tell me the problem. I have wasted 2 days on this.
    Mallik.
    null

    You're running this EJB in iAS, right?
    You have to grant JAVAUSERPRIV to the user running your EJBs so that it is allowed to open a JDBC Thin socket out of the JVM to the backend database.
    null

  • How can I avoid memory leak problem ?

    I use Jdev 10.1.2 . I have a memory leak problem with ADF .
    My application is very large . We have at least 30 application module , each application module contain many view object
    and I have to support a lot of concurrent users .
    as I know ADF stored data of view object in http session .
    and http session live is quite long . when I use application for a while It raise Ouf of Memory error .
    I am new for ADF.
    I try to use clearCache() on view object when I don't use it any more .
    and call resetState() when I don't use Application Module any more
    I don't know much about behavior of clearCache() and resetState() .
    I am not sure that It can avoid memory leak or not .
    Do you have suggestion to avoid this problem ?

    ADF does not store data in the HTTP session.
    See Chapter 28 "Application Module State Management" in the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://download-uk.oracle.com/docs/html/B25947_01/toc.htm for more information.
    See Chapter 29 "Understanding Application Module Pooling" to learn how you can tune the pooling parameters to control how many modules are used and how many modules "hang around" for what periods of time.

  • I'm switching to Android soon, how can I avoid the iMessage problem?

    So, I'm switching to a Galaxy S5 soo, and I was wondering what can I do now to be able to avoid the iMessage issue that everyone is having? My iPhone 5s is the only apple device I use, and the only device that recieves iMessages.
    Thanks!

    Turn off iMessage, Find My iPhone, Facetime and iCloud while your phone is still active.

  • How can i avoid ora-01706 error in Oracle 9i db?

    Can someone help me with the error ora-01706 user function result value was too large in Oracle 9i ?
    I am trying to parse the xml with namespace and CDATA tags. The example of the query i have used is as follows.
    select extractvalue(
    xmltype(
    extractvalue(xmltype(col1),'/SubmitPart/OrderRequest/OrderXML','xmlns="http://www.w3schools.com/ravi/srpf"')
    ),'/OrderRetrieval/OrderDetails/Locations/Location/L2_Is/I/IProperties/Edge/RAG','xmlns="http://www.w3schools.com/ravi/srpf"')
    from table;
    I am getting the error
    ora-01706 user function result value was too large
    Please let me know how can i get rid of this. my db is Oracle 9.2.0.1.0

    You are probably better off posting this question in the XML DB forum. You are hitting a 64K limit in 9i. You'll have to come up with a way to reduce the data you need to extract to under 64K.

  • I want to upgrade from Tiger to Snow Leopard on my 2008 MacPro. How do I avoid problems with the upgrade process?

    I want to upgrade from Tiger to Snow Leopard on my 2008 MacPro. How do I avoid problems with the upgrade process?

    #1 Do a complete bootable backup of your drive before upgrading. That way should anything happen you can revert back to the start and try again.
    Make sure you meet Snow Leopard 10.6 Technical Requirements - http://support.apple.com/kb/SP575
    You might also want to make sure you don't have software issues with SL:
    A Mac OS X 10.6 Snow Leopard Application Compatibility List - http://snowleopard.wikidot.com/

  • HT2729 Purchased HD movie on ITune and tried to watch it on my TV using my IPAd Mini as the source and got flashing white images and then finally a motive that it could be watched using the TV aas a monitor.  Why? How do I avoid this problem?

    Recently while on vacation I tried to use my IPad Mini to watch a movie down loaded from ITunes and could not.  Initially I get flashing white lights across the TV monitor I was using so a group of us could watch the movie, Wreck It Ralph.  A few minutes later I was informed that the TV was not an acceptable viewing device.  Why?  How do I avoid this going forward?

    I connected an HDMI cable to a connector that I bought at an Apple store.  The connector connects the HDMI cable to the IPad Mini and the HDMI connects to the TV

  • HT4740 How can I avoid or solve the problem of Final Cut Pro crashes when trying to Show Events Library?

    When I try to Show Events Library in Final Cut Pro, it crashes each time. Please tell me how do I work around this problem?

    Try creating a new (temporary) folder and putting all your events in there - then launch FCP X.
    If you can open the Browser, then it's possible one or more of the clips in one of your events is corrupt. Close the app and move the events back into their original places one by one (re-starting FCP X each time). This will help you find the event which has the corrupt file in it.
    If isolating the events has no effect, I suggest you trash your preferences.
    Unexplained faults like this can often be fixed by clearing out FCP X's preferences (for some reason, they get knotted up from time to time).
    Download Digital Rebellion's Preference Manager (free, simple to use, and perfectly safe, both to download and use).
    http://www.digitalrebellion.com/prefman/
    With Preference Manager, you can backup the Prefs when FCP X (or any of the Apple Professional Applications) are working normally. Then when either of the applications are acting strangely, Trash the Preferences, then Restore from your backups (just a mouse-click).
    If you trash the prefs and don't restore them, you will need to manually restore all your FCP X settings again, so it's a great idea to backup Preferences from time to time when FCP X is working well, then your backups are up to date.
    Doesn't fix every problem, but it fixes a lot.
    Andy

  • Files recently downloaded from Canon Legeria FS306 do not play the audio. Can hear audio on camera or downloading same files to a PC. Also hear audio on earlier files downloaded from same camera to iMovie '11. How do I avoid problem & recover lost audio?

    Files recently downloaded from Canon Legeria FS306 to iMovie '11 do not play the audio. I can still hear audio on the camera or by downloading the same files to a PC. Can also hear audio on earlier files downloaded from the same camera to iMovie '11. How do I avoid this problemand recover lthe ost audio?

    The first thing to try is to run Software Update (the Update tab in the Mac App Store.). This was an issue a couple of releases ago, and an update seemed to fix it.
    If you are already at the most recent version of iMovie, then I don't know how to solve you issue. Maybe someone else will have some ideas.

  • What does "extracted channel PDF" mean and why does it continually duplicate on my desktop?  I think it happens when I move a file in Finder to another file and when I copy some web files.  How do I avoid this on my Mac (Mavericks)?  Thanks for your help!

    What does "extracted channel PDF" mean and why does it continually duplicate on my desktop?  I think it happens when I move a file in Finder to another file and when I copy some web files.  I have to immediately move to trash all the duplications on my desktop.  How do I avoid this on my Mac (Mavericks)?  Thanks for your help!

    What application is set to open PDF files? If you CNTRL click on the file and open with Preview does the problem occur?
    If not change the default application to open PDF files to Preview.
    You can do this by highlighting the file and either use CMD i or Get Info , this will open a window with the info on the file with an option to change the application that opens the file.
    That's all I can think of.

  • How we cn avoid the sequence in remote tables through global temporary tabl

    Hi,
    We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
    INSERT INTO xx_interface_qua
    (interface_id,
    list_line_interface_id, excluder_flag,
    qualifier_context, qualifier_attribute,
    qualifier_attr_value, qualifier_precedence,
    comparison_operator_code, start_date_active,
    end_date_active, list_header_name, list_line_no,
    creation_date, created_by, last_update_date,
    last_updated_by, interface_attribute1
    VALUES (xx_interface_qua_s.NEXTVAL,
    ttt, 'Y',
    xxx, xxx2,
    xxx3, xxx4,
    '=', SYSDATE,
    NULL, xxx4, -1,
    SYSDATE, '-1', SYSDATE,
    '-1', 44 );
    We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
    But how we cn avoid the sequence in this case as we do not know the sequence in remote side.
    Please suggest any other way to improve the performance.
    Regards
    Das

    797846 wrote:
    We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
    We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
    But how we cn avoid the sequence in this case as we do not know the sequence in remote side.Does not make sense. I/O is the slowest database operation.
    You have an unknown performance problem (that you claim is due to a sequence, but failed to provide any evidence for). Now you want to create more I/O, by writing the data twice. Once into a temp table and then again into the destination table. And do that in order to increase performance?
    I do not see how this can solve the underlying, and unknown, performance issue that you claim exists.
    Any problem solution needs to start with correctly and comprehensively identifying the problem.
    You cannot solve a problem without first knowing WHAT the problem is.

  • Every time I sync my iCal computer with my iPhone 4 or iPad, duplicate entries are generated on both systems. What am I doing wrong or how can I avoid the duplications?

    Every time I sync my iCal on my computer through iTunes with my iPhone 4 or iPad, duplicate entries are generated on both systems. What am I doing wrong or how can I avoid the duplications? I have been doing this for several years and this problem is a more recent issue, like in the last 6 months. I have been deleting the duplicate entries, on both systems, but some duplicates reappear through "general" entries that are connected to the correct color for a Calendar, but not the name. I am going nuts and wasting tons of hours trying to get the 3 calendars to sync without generating duplicate entries.

    Choose one of the Calenders on ONE of the computers OR the MobileMe as the Master / correct account.
    The REINITAILISE the data of MobileMe within preferences on the computer defining the datatransfer correctly (in the advanced box of preferences). The synchronise iphone contacts and calender directly on-line to MobileMe.
    I posted a question on this today, and gave my own reply !
    Regards,
    Kevin

  • How can we avoid duplication of records in database while inserting records

    Hi,
    In my scenerio,while inserting the same records through idoc duplication of records is happening in database.How can i avoid this.

    Divya,
    First its a wrong data, because you cannot have the same data for any condition. Probably its a data problem. Please check with the datbase team and ask them why is it so? They should handle on their end.
    Anyways if the above dont work and if you ahve duplicate records then probably you need to come up with a query using select distinct. If this doesnot work then if the duplicates comes into mapping, you might selecting some fields which are common. So you can use a splitbyvalue(on value change) for those records, so even if there are three records it takes only one record. If you have 4 or 5 common values then you can concat them and then use the splitbyvalue change.
    Else an adapter module should help you out in sender comm. channel after picking the records.
    For an idea can you rajs response in this thread:
    Duplicate records
    Regards,
    ---Satish

  • How can i avoid printing full pages?

    How can I avoid printing full pages when printing a photo from my iphone to my hp envy?

    Hi,
    While pritning with Apple Airprint, the image will print as is..
    You may find some more customization steps by using the HP Print Home & Biz app which allow some more customization of the printout:
    Follow the steps below to find how to get the app:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02775166&cc=us&dlc=en&lc=en&product=3692888&tmp...
    Below you may find some more customization options of the app:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01930282&cc=us&dlc=en&lc=en&product=3692888&tmp...
    Regards,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How can I avoid bit stuff?

    ---- card=pci-can/2---
    how can I avoid bit stuff?
    when i am using ncgetattr.vi,the return value of series2 error/arb captue is 10100010.
    Then how can i resolve the problem!
    thanks.
    Work hard and enjoy life.
    Love CVI and Labview!
    Certified Labview Developer

    Hi 侠客
    The Series2 error/arb capture register indicates where the last error happened. In this case, the bit stuffing rules (not more then five consecutive bits of the same state) where violated. Typical causes are:
    Baudrate mismatch (most likely no commmunication at all possible)
    Improper termination (please see chapter 4 of the NI-CAN Hardware and Software Manual for more information)
    Wirering schema not compliant with the CAN specification (ISO 11898), e.g. stub/drop length too long, star-type setup instead of a chained setup 
    -B2k

Maybe you are looking for

  • Transaction aborts after installing ODAC 12c Release 3

    I have .net code that used a transaction scope which works fine using ODAC 11g Release 4, but fails with "Unable to enlist in a distributed transaction" using ODAC 12c Release 1,2, or 3.  The transaction to a single database.  I am at a loss for what

  • InDesign CC - Spell check not working.

    I can purposefully type a misspelled word in InDesign and the Spell Check doesn't catch it. In fact it doesn't seem to work at all.

  • Purge tables

    Hi, How can we purge/reset tables (data) like v$sql, v$sqlarea and all others apart from restarting the instance? Thanks!

  • Failed to install : error code 1

    I cannot get the installer to complete installation.  It gets about half way through the down load then gives me an Adobe Installer error box indicating: We've encountered the following issues: Creative Cloud desktop failed to install. (Error code: 1

  • Need help with adding a PRELOADER to an existing .fla file

    I have a 9-layer .fla file that needs a preloader. How can I shift all of the layers to make room for a preloader? Thanks