Using DataSource from a user-defined thread

Using Websphere 5.1.1, I have a servlet that launches a special thread, which accesses a database (through a DataSource).
It's unusual, but it's a requirement.
So it would in the lines of (ommitting error handling):
public class MyServlet extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse resp){
        InitialContext ctx=new InitialContext();
        final DataSource ds=(DataSource)
               ctx.lookup("java:comp/env/myDataSourceRef");
        new Thread(){
             public void run(){
                  Connection con=ds.getConnection();
                  ... run some JDBC code
                  con.close();
        }.start();
}When running this, I get a warning :
"J2CA0075W: An active transaction should be present while processing method initializeForUOW"
According to IBM, that follows J2EE spec, because
Eventually (i.e. J2EE 1.4) spun threads from a Servlet accessing a database outside of a transaction will not be supported(Quoting from: http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&q=J2CA0075W&uid=swg21109248).
But then, if the problem is a lack of transaction, how can one guarantee a transaction is present ?
I have already tried the following, in vain:
1) Making sure the datasource is registered as a web reference (in web.xml), with transaction isloation level set to READ_COMMITTED.
2) Invoking con.setAutoCommit(false), which is probably not recommended, but I tried it anyway.
3) I've considered moving the call "con=ds.getConnection" out of the thread, and into "doGet". However, my application logic won't allow it.
Would anyone happen to know how to make sure such a transaction is present ?
Thanks very much.

A map with a constant or mapping input parameter that uses a function should call the function one time.
There was a bug(5663912) in 10.2.0.1 that was fixed in 10.2.0.2. If the SQL statement is using a PLSQL variable which has the initial value of the function result then this is working OK, if the SQL statement calls a 'GET_' function which in turn executes your function then you are not using the fix.
Cheers
David
(The intermediate code generation shown in the mapping editor is not the full blown code generator).

Similar Messages

  • How to use classes from different user defined Packages

    well i made 2 packages... one containing employee class and realted matter and other contaning bankaccounts and bank related work... now how can i use them in an another.. i know about the import statement but still couldn't make it work.... now suppose iam makin a obejct of employee class and passing in name and salary and all in the constructor... now i want that when i create the bankaccount class then the name of the employee should be passed to the bankaccount class so that it can assigen a account no. .. now how do i do this as when i create a object of employee class its made at runtime.. and if i create a object of bankaccount.. how wil it take that name as before goin to bank account i should already have a list of emplyees and then this list should be worked upon by the backaccount class to assign the accountno.s
    Hope my question was clear... would appriciate a explanation and guidance!!!

    Thank you so much ... i was able to solve the problem... i passed the object in the constructor of the accounts class and it all worked out the way i wanned... thank you so much... it wasn't that difficult but the idea was just not clicking...this place is wonderful... everyone rocks!!! and so greatful about all the help.. please keep up the good work and even i will try to contribute as much as possible!!

  • How can I call a stateful webservice from a user-defined XPath function?

    I'm calling a stateful webservice from a BPEL process using a PartnerLink which implements Custom Header Handler classes to handle the session state, storing the cookie as a property of the PartnerLink.
    I'd also like to call this same stateful webservice, in the same session, from a user-defined XPath function enabling me to call this from an XSL Transformation.
    Is this in any way possible? Can I access the cookie and attach it to the webservice call made by the user-defined XPath function?

    Actually, as long as the servlet returns valid javascript, you can indeed "call it" from the client. It will initiate a request and return the result to the browser.
    This example uses Perl, but it could be easily modified to go to a servlet instead.
    Note that it is only supported in DOM browsers (IE6+/NN6+/etc)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> Test server-side JS </title>
    </head>
    <body>
    <script type="text/javascript">
    function checkIt(variable, value)
    var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;
    var body = document.getElementsByTagName('body').item(0)
    var scriptTag = document.getElementById('loadScript');
    if(scriptTag) body.removeChild(scriptTag);
    script = document.createElement('script');
    script.src = newScript;
         script.type = 'text/javascript';
         script.id = 'loadScript';
         body.appendChild(script)
    </script>
    <p>Test.</p>
    <form id="f1" action="">
    <input type="text" name="t1" id="t1" onChange="checkIt(this.name, this.value)">
    </body>
    </html>
    validateJS.cgi
    #!/opt/x11r6/bin/perl
    use CGI qw(:all);
    my @valArray = split(/=/,$ENV{QUERY_STRING});
    print "Content-type: text/javascript\n\n";
    # myPass is the password
    $myPass = "foobar";
    if ("$valArray[1]" eq "$myPass")
    print "alert(\"Success!!\")";
    else
    print "alert(\"Failure!!\")";

  • How to fill the records from a User Define Table to PO item Grid

    Hi To all,
    I need to fill data from User Define table records into Purchase Order Item Grid.
    I created an UDF Filed in PO - Header Part - "PRS"(Filed Name)
    By using Formatted Search in itemcode column, i called a query,
    "Select itemcode, qty from (@user define tablename) where PRS = $http://OPOR.U_PRS"
    For eg:
    Output from querry
    ItemCode Qty
    ABC 1
    DEF 2
    DFG 7
    SDGD 9
    By using formatted search it is filling only first data in to itemcode column in PO Grid.
    Please help, how can i fill ALL the data in to my PO Grid?
    Thanks in Advance
    SAGAR

    The easisest way is to create datasource and the result bind to grid.
    Datasource:
               oDBDataSource = oForm.DataSources.DBDataSources.Add("@usertablename")
                Dim xoConditions As SAPbouiCOM.Conditions
                Dim xoCondition As SAPbouiCOM.Condition
                xoConditions = New SAPbouiCOM.Conditions
                xoCondition = xoConditions.Add
                xoCondition.BracketOpenNum = 1
                xoCondition.Alias = "u_zn"
                xoCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                xoCondition.CondVal = "cond"
                xoCondition.BracketCloseNum = 1
                oDBDataSource.Query(xoConditions)
    binding (example for matrix, in grid is simillar)
                oMatrix.Clear()
                Dim cols As SAPbouiCOM.Columns
                Dim column As SAPbouiCOM.Column
                cols = oMatrix.Columns
                column = cols.Item("colX")
                column.DataBind.SetBound(True, "@usertable", "u_x")
    oMatrix.LoadFromDataSource()
    hoep it helps
    Petr

  • Using Xcontrols in the user defined express vi's

    Hi All,
                            I am actually using a Xcontrol inside a user defined express that we develop. The xcontrol is working as expected when i use it in the standard vis. But when i use it in the express, simply it crashes the LabVIEW and i need to restart the LabVIEW again. I am worried with this.
                            I put break points in the Facade vi of the xcontrol to know what is happening. But, i am not able to debug as the configure vi comes infront as modal even though the Source, sub and the configure vi of the express was not been configured as modal.
                        How to solve this problem?
                        Is there any restriction in using xcontrol with express vi's?
                        I am refering the Express Tool Kit Manual.pdf. Is there any other documents to know about the operation of the express vi's?
    Thanks,
    Pandiarajan R

    Hello Pandiarajan,
    Since I didn't see it mentioned, I'm going to presume (hope) you're using 8.0.  In LabVIEW 8.0, certain parts of XControls ran in a different application instance than where the VI was.  This was a source of many issues related to XControls.  In your case, since Express VI configuration pages also run in a separate application instance (and a different one than the XControls), I suspect this is related to the problems you are seeing.  If this is the case, it may not be possible to use an XControl on the front panel of an Express VI config page in 8.0.
    The resolution to many of these issues was to allow these XControl parts to run in the application instance of the VI whose front panel contains the XControl.  This fairly substantial change did not make it in until LabVIEW 8.2.
    If you are already using LabVIEW 8.2, it may not be an easy issue to troubleshoot, but I'd like to help isolate this issue.  If you can simplify your XControl / Express VI into something that you could package and attach to this thread, I'd be willing to take a look at it.

  • Using bind variables in user defined reports

    How do I go about using a bind variable in a user defined report?
    Here's a trivial example in SQL*Plus:
    var ublocksize number
    begin
    select value into :ublocksize
    from v$parameter
    where name = 'db_block_size';
    end;
    select :ublocksize from dual;
    This code does not work in raptor.
    The error displayed is:
    Missing IN or OUT parameter at index:: 1
    Vendor code 17041
    any ideas?

    You also have a second issue of supporting the following syntax in SQL scripts:
    var ublocksize number
    begin
    select value into :ublocksize
    from v$parameter
    where name = 'db_block_size';
    end;
    We are itterating to support all SQL plus commands
    Mike

  • Prevented from creating User Defined Metric

    I am using Oracle Enterprise Manager 10g Database Control.
    When I try to create a User Defined Metric I get a screen that says:
    Information:
    You cannot create a User Defined Metric because host <my_host> is currently unavailable. Try again later when it becomes available.
    I cannot find any information on how to resolve this.

    In case anyone else is looking for this answer - at least what worked for us.
    It seems Oracle is parsing the "select TO_CHAR(SID,'99999'), other_column from ...." by comma instead of by what the output is coming back with. So in this case it thinks the output has three columns because of the two commas in the select clause. So we just went with an inline view similar to select a.sid, a.other_column from (select TO_CHAR(SID,'99999'), other_column from .... ) a and that worked for us. Assuming its a version thing since the non-inline view worked for someone else. We're on 11.1 of the oms.

  • Error Using imported .JAR in user-defined function

    Hi All,
    I am trying to use jar files provided to me in user defined function as follows:
    DataEncryption temp = new DataEncryption();
    String ret = new String();
    ret = temp.getEncryptedData(a);
    return ret;
    All jar files working perfectly in java software, But when i am trying to test the mappings by using above user-defined function.
    I am catching the error and put in target field then, I am getting following message in target field:
    "An error occured in getEncryptedData method :  java.lang.SecurityException: The provider SunJCE may not be signed by a trusted party"
    Please help in finding the error.
    Regards

    Rohan
    Check if the XI Server JRE is the same as the client machine on which you have compiled your JAR.
    1.4 has had this issue and i remember seeing it in a few forums.The problem should not occure in 1.5

  • How to Use Sequence Object Inside User-defined Function In SQL Server

    I'm trying to call sequence object inside SQL Server user-defined function. I used 
    Next Value for dbo.mySequence  to call the next value for my sequence created. But I'm getting an error like below.
    "NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
    Is there any standard way to call sequence inside a function?
    I would really appreciate your response.
    Thanks!

    The NEXT
    VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
    https://msdn.microsoft.com/en-us/library/ff878370.aspx
    What are you trying to do? Can you give us an example and required output?
    --Prashanth

  • Using SQL query on user defined table

    Hi all,
    i'am currently working on a project which use user defined table and i would like to know if sap allow us to do insertion/deletion/update on those table using sql query or if we have to use the DI only?
    thanks
    Best regards,

    Hi,
    Definitely you can insert in UDT. You can update but you cant change the Code field after added the rest of the field
    can be updated. You cant delete in UDT but you cant delete anytime in SQL Management Studio.
    THanks.
    CLint

  • How to add a DataBase Field in PLD from a User Defined Table

    Hi All,
    Please tell me how should i add a database field in PLD from User Defined Field...
    The DropDown for tables in the Property window does not shows the User Define tables...How should i see them...
    Thanx in Advance
    Manish

    In PLD choose object Database. Then press Alt + table combobox, this will show the UDT. Then choose the column.

  • Calling a std user exit from a user defined user exit

    hi
    I have a standard User Exit. I want to call it from a User Exit created by me something like zaaabbbb.
    Can you please tell me the procedure how to do it ?

    Hi,
    If the user exit is a Z include in a function module then you can call the function module like any other function module passing the required parameters. For example CALL CUSTOMER-FUNCTION '002' in transaction VA01 corresponds to function module EXIT_SAPMV45A_002. You can call this function module like you do any other function module.
    CALL FUNCTION 'EXIT_SAPMV45A_002'
      EXPORTING
        i_tvak        =
        i_tvta        =
        i_vkgrp       =
        i_vkbur       =
    * IMPORTING
    *   E_KUNNR       =
    If the user exit is a subroutine in an include in SAP name space (For example subroutine userexit_delete_document in include mv45afzz), then find out the main program in which the include is included (for example mv45afzz is included in program sapmv45a). Once you have done that you can using the following statement to call the subroutine.
    PERFORM <subroutine name> IN PROGRAM <program name>.
    For Examaple
    PERFORM userexit_delete_document IN PROGRAM sapmv45a.
    Please make sure that you use the main program name (In our example sapmv45a) and not the include name (in our example mv45afzz).

  • Using Reports from End User Console.

    I want to show the reports tab and the sub tabs in the end user console.
    I have copied the reports folder into the user folder and have modified the "End User Navigation" form , giving the URL of all the jsps.
    By this I can see the reports tab in the End user console, but when I click the tab, it redirects to the Admin console login page, and after logging into Admin console login page only I can navigate the other report sub tabs.
    Please let me know if there is any way to use the reports from End user console, without the secondary loging (into Admin console).

    Do you have to implement whole report TAB or do you want to run only one report.

  • Is there a way to use music from multiple users itunes libraries on one iMac for a slideshow in Aperture?

    I am trying to put together a slide show for a trip my wife and I took to England. I would like to be able to use music from both our itunes libraries in the slide show. I am using Aperture to create the slide show since it seems to be more versatile than iPhoto for this. Only trouble is that when I log into my username on the iMac I only see my iTunes library and similar when logging into her username. We have different music but would like to use some from each library in the slide show.

    You can only use one library at a time in an Aperture slideshow, so I'd suggest to simply collect the audio that you want to use in a folder (export the songs from both iTunes Libraries) and then import this folder to Aperture. Now you have a project containing the audio files; you will see it in the Aperture Audio section of the audio Browser, right above the iTunes section.
    You can use the Apperture audio just like the audio in iTunes to drag to the timeline of your slideshow.
    Regards
    Léonie

  • When I use a "customized header" (user-defined field) in a message-filter rule, the rule does not apply correctly.

    Hi, I want to distinguish two messages via message filters. One is a duplicate of the other and I want to delete it.
    The filter is defined as follows:
    - match all of the following
    - To or Cc contains %[email protected]
    - Return-Path doesn't contain [email protected]
    - Perform these actions: Delete Message
    I expect that only message 2 (cf. below) is deleted.
    However, actually both messages are deleted.
    I assume this is a bug with the "customized headers" (here: "Return-Path").
    If instead I replace the third line of the filter by "Return-Path contains [email protected]", then both messages are not deleted.
    I assume this is also a bug with the "customized headers".
    Thanks for checking!
    Frank
    The following data is a bit scrambled (some chars deleted in each name), hence anonymized.
    Message 1 looks like this (only headers shown):
    From - Sun Sep 14 16:12:35 2014
    X-Account-Key: account1
    X-UIDL: 0LqBQa-1Xxp4o3tWC-00dm2v
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-Keys:
    Return-Path: [email protected]
    Received: from mout.gmx.net ([212.227.15.19]) by mx-ha.gmx.net (mxgmx101) with
    ESMTPS (Nemesis) id 0LqBQa-1Xxp4o3tWC-00dm2v for <[email protected]>; Sun, 14
    Sep 2014 14:39:59 +0200
    Received: from d103a3.x-mailer.de ([212.162.15.62]) by mx-ha.gmx.net
    (mxgmx011) with ESMTPS (Nemesis) id 0LgMmy-1Y5YJr3foC-00ndfs; Sun, 14 Sep
    2014 14:39:55 +0200
    Received: from [84.171.158.48] (helo=deborahsvaio)
    by d103.x-mailer.de with esmtpa (Exim 4.63)
    (envelope-from <[email protected]>)
    id 1XT95v-00087S-B1; Sun, 14 Sep 2014 14:39:55 +0200
    From: "Prof. Dr. kamper" <[email protected]>
    To: "'Hambug, Frank'" <[email protected]>,
    "'sdd MA-L, Aktive'" <aktive%[email protected]>
    References: <[email protected]> <[email protected]> <[email protected]> <[email protected]>
    In-Reply-To: <[email protected]>
    Subject: Schriftzug
    Date: Sun, 14 Sep 2014 14:40:12 +0200
    Message-ID: <002e01cfd019$0761bf40$16253dc0$@de>
    MIME-Version: 1.0
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    X-Mailer: Microsoft Office Outlook 12.0
    Thread-Index: Ac/Oy/dRV0TPlboMSoegvir2geHMYwBTDdNQ
    Content-Language: de
    X-Info: valid message
    X-Info: original Date
    X-UI-Out-Filterresults: notjunk:1;
    Envelope-To: <[email protected]>
    X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3;
    X-GMX-Antivirus: 0 (no virus found)
    Message 2 looks like this (only headers shown):
    From - Sun Sep 14 16:12:34 2014
    X-Account-Key: account1
    X-UIDL: 0MKuBs-1XT95v3qgS-0003Ia
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-Keys:
    Return-Path: [email protected]
    Received: from d103a3.x-mailer.de ([212.162.15.62]) by mx-ha.gmx.net
    (mxgmx011) with ESMTPS (Nemesis) id 0MKuBs-1XT95v3qgS-0003Ia for
    <[email protected]>; Sun, 14 Sep 2014 14:39:55 +0200
    Received: from [84.171.158.48] (helo=deborahsvaio)
    by d103.x-mailer.de with esmtpa (Exim 4.63)
    (envelope-from <[email protected]>)
    id 1XT95v-00087S-B1; Sun, 14 Sep 2014 14:39:55 +0200
    From: "Prof. Dr. kamper" <[email protected]>
    To: "'Hambug, Frank'" <[email protected]>,
    "'sdd MA-L, Aktive'" <aktive%[email protected]>
    References: <[email protected]> <[email protected]> <[email protected]> <[email protected]>
    In-Reply-To: <[email protected]>
    Subject: Schriftzug
    Date: Sun, 14 Sep 2014 14:40:12 +0200
    Message-ID: <002e01cfd019$0761bf40$16253dc0$@de>
    MIME-Version: 1.0
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    X-Mailer: Microsoft Office Outlook 12.0
    Thread-Index: Ac/Oy/dRV0TPlboMSoegvir2geHMYwBTDdNQ
    Content-Language: de
    X-Info: valid message
    X-Info: original Date
    Envelope-To: <[email protected]>
    X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3;
    X-GMX-Antivirus: 0 (no virus found)

    Please reffer to PHP section PHP

Maybe you are looking for