Does transaction manager also releases the connections ?

Hi All,
I've a doubt regarding release of connection in transaction handling scenarios in EJB.
Let us assume I have an EJB method associated with a transaction attribute as Requires New (i.e. the ejb method is associated with container managed transaction).
Within that method two diffreent databasess are accessed, connections are created, databases are updated but connections are not realeased.
The code goes similar to the one given below -
public void beanMethod1()
InitialContext cntx = new InitialContext();
javax.sql.DataSource ds1 = cntx.lookup("dataSourceName1");
javax.sql.DataSource ds2 = cntx.lookup("dataSourceName2");
java.sql.Connection conn1 = ds1.getConnection();
ds1.setAutoCommit(false);
PreparedStatement pst1 = ds1.prepareStatement("Qyery1");
pst1.executeUpdate();
java.sql.Connection conn2 = ds2.getConnection();
ds2.setAutoCommit(false);
PreparedStatement pst2 = ds2.prepareStatement("Qyery2");
pst2.executeUpdate();
Now in this context my doubt is - will the transaction manager, along with handling commit/rollback, release the connections also (once commit/rollback is over) ? Or releasing of connections need to be handled in the bean method ?
If releasing connections has to be handled in the bean method, then how does transaction manager execute a commit/rollback on a released connection ?
The same doubt can be extended to bean managed transaction also where transaction boundarry is demarcated using javax.transaction.UserTransaction object's begin(), commit() and rollback() methods.
It will be a real help if anyone please throw some light on this doubt.
Thanks in advance,
Sourav

Hi,
Your code needs to release (i.e., close) the connections it uses; this is outside the TM responsibility scope.
The commit or rollback is not a problem, because the corresponding XAResource (which is the
transaction manager's handle to your connection) can be used even after your connection
has been closed in the application code. That is the catch about XA, and it allows the whole
mechanism of connection pooling and DataSources to work properly.
Hope that helps,
Guy

Similar Messages

  • Oci_close does not release the connection when using DRCP

    Hello everyone,
    we are currently testing the deplyment of DRCP with 11g. I have the whole thing setup (correctly to my best knowledge), but I am facing an issue. The call to oci_close does not seem to release the connection to the pool as I would expect and therefore we see similar behavior like we were getting without using the DRCP.
    Our setup is using two RAC instances running 11.1.0.6.0, I am using PHP 5.1.6 with PECL installed oci8 1.3.4. The DRCP pool is configured and started, each with 100 max servers.
    When the webserver is idle it looks, well, idle.
    SQL> SELECT INST_ID,NUM_BUSY_SERVERS FROM GV$CPOOL_STATS;
    INST_ID NUM_BUSY_SERVERS
    1 0
    2 0
    The script is as simple as it gets:
    <?php
    $c = oci_pconnect('scott','tiger','IWPPOOLED');
    $s = oci_parse($c, 'select * from emp');
    $r = oci_execute($s, OCI_DEFAULT);
    oci_close($c);
    sleep(30);
    ?>
    What I would expect is that the script would connect to the pool, do the work for a tiny moment and then release the connection for usage by other script.
    But after I point the browser to the script, I get a 30 second loading time (as expected) but the server is busy all the time, like this:
    SQL> SELECT INST_ID,NUM_BUSY_SERVERS FROM GV$CPOOL_STATS;
    INST_ID NUM_BUSY_SERVERS
    1 0
    2 1
    After the 30 second sleep, it is released and busy servers are back to 0.
    If I load the server with ab using 256 connections:
    ab -n 1000000 -c 256 -k http://mywebserver/ocitest.php
    the pool is maxed out and the connects are stalling:
    SQL> SELECT INST_ID,NUM_BUSY_SERVERS FROM GV$CPOOL_STATS;
    INST_ID NUM_BUSY_SERVERS
    1 95
    2 95
    My network config for this service is following:
    IWPPOOLED =
    (DESCRIPTION =
    (LOAD_BALANCE=ON)
    (FAILOVER=ON)
    (ADDRESS = (PROTOCOL = tcp)(HOST = 10.1.16.33)(PORT = 1521))
    (ADDRESS = (PROTOCOL = tcp)(HOST = 10.1.16.34)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = IWP)
    (SERVER=POOLED)
    (FAILOVER_MODE=
    (TYPE=SELECT)
    (METHOD=BASIC)
    (RETRIES=5)
    (DELAY=3)
    The phpinfo() look like this:
    OCI8 Support enabled
    Version 1.3.4
    Revision $Revision: 1.269.2.16.2.38.2.20 $
    Active Persistent Connections 1
    Active Connections 1
    Oracle Instant Client Version 11.1
    Temporary Lob support enabled
    Collections support enabled
    Directive Local Value Master Value
    oci8.connection_class IWPAPP IWPAPP
    oci8.default_prefetch 100 100
    oci8.events On On
    oci8.max_persistent -1 -1
    oci8.old_oci_close_semantics Off Off
    oci8.persistent_timeout -1 -1
    oci8.ping_interval -1 -1
    oci8.privileged_connect Off Off
    oci8.statement_cache_size 20 20
    I am using the instant client for 11g
    Any ideas?
    Thanks!
    Michal

    Don't forget to use oci_free_statement($s); See "Closing Oracle Connections" in The Underground PHP and Oracle Manual. (I was just simplifying this example today for the next release of the manual).
    You may also see the "dedicated optimization", where a pooled server in a non- maxed-out pool is retained (unless needed by another PHP process) under the assumption that the initial PHP process might become active again. See http://www.oracle.com/technology/tech/php/pdf/php-scalability-ha-twp.pdf
    Feel free to email me offline (see my profile) if there are questions/data you don't want to post.
    cj
    Edited by: cj2 on Oct 16, 2008 8:12 AM

  • Release the connection in JMS Adapter

    Hi,
    I’m sending the message to JMS queue (queue is running in weblogic server) using JMS Adapter in BPEL. My question is how to release the weblogic connection once the message produced to queue. It is happen automatically or we have to release the connection explicitly. If it explicit handle means how to do it?
    It would very helpful for me if you send any reference doc or url about this.
    Thanks in Advance.
    Thanks
    Chandramohan

    The JMS adapater of SOA will handle this for you. You do not have to do anything with closing connections.
    Marc

  • HT5163 Hi, I'm trying to extract the nano sim tray on my new Ipad air. I know how it should come out but the tool does not seem to release the tray. Any ideas?

    Hi, I'm trying to extract the nano sim tray on my new Ipad air. I know how it should come out but the tool does not seem to release the tray. Any ideas?

    Thanks. It needed more pressure than I expected!
    Didn't want to break it when it's less then 24 hours old!
    BB

  • Apple has placed a temporary authorization amount hold in my card for repair. My old iphone has been received by apple. how long does it take to release the amount?

    Apple has placed a temporary authorization amount hold in my card for repair. My old iphone has been received by apple. how long does it take to release the amount?

    How long it takes depends partially on your bank. Once they release it, it could take several days for the authorization to roll off of your account. It is generally not a problem unless you're using a debit card, which will lock the funds in your checking account and make them unavailable, which I presume you did or you wouldn't be worried about it.
    This is not unique to Apple. That's a problem when using debit cards for any purchase.  Several years ago, when gas prices spiked to $4 a gallon here, gas stations would routinely authorize and hold upwards of $100 every time you tried to pay at the pump. Created some major headaches for the working stiffs just trying to get to their jobs and pay the bills.

  • Does 'software update' also update the display drivers?

    Does the iMac software update also update the graphics card drivers, or am I better off trying to install them manually?
    My iMac has the Nvide 7600 GT display. I'm having a display issue with Adobe Dreamweaver 8, and I suspect it is an issue with my graphics card. I don't know how to tell if my graphics card driver s/w is up-to-date or whether I am better manually installing the driver?

    If the app is a PPC program it will always run in Rosetta emulation mode on an intel mac. You can choose to run universal apps in rosetta emulation if you want, but it usually sacrifices performance (program will run slower). To check this, go into the apps folder, command click on the app and select get info. It will tell you what kind of app it is, universal or PPC. For universal apps you have an option to run in rosetta. Check that box and the next time you start that app it will run in rosetta emulation mode. Again, this will result in some performance loss for that app, and it isn't necessary to run the app. So, that being said, I don't know why you would need to do that. Maybe someone else here can answer that question.
    20" iMac 2.0 GHz Intel Core Duo   Mac OS X (10.4.9)   60 GB iPod Video

  • When you change your Apple ID Password does it log out all the connected accounts?

    When you change your apple id password does it log out all the accounts synced to it or connected?

    You will need to logout of the account on all clients after changing the password, then login with the new one.

  • Nokia Connection Manager - Cannot use the connecti...

    Can someone PLEASE try and help me
    I have the following details:
    Phone: Nokia C5;
    Operating system: Microsoft Windows XP Service Pack 2
    Nokia PC Suite: Version 7.1.60.0
    I cannot use bluetooth & USB connection. When I try to select it in the Connection Manager I get an error message "  Cannot use the connection type. Check that all the needed hardware, software and drivers are available. (Code: OpenMedia) ". I have tried to reinstall nokia pc suite but no result.  The connection worked before. The PC Suite of my computer was upgraded and now the bluetooth & usb are not working any more.
    Please Help Me
    Attachments:
    Nokia_Connection_4679E9820AC32C34D11CBCDBA8237BA5_5.jpg ‏20 KB

    Could you please try this?
    I am not sure whether this will solve your problem but you could try this once.
    1. Disconnect your phone from PC if connected.
    2 .Open Control Panel and go to ‘Programs and Features’
    3. From the list of available programs, choose ‘Nokia Connectivity Cable Driver’
    4. Click on the ‘Change’ button on top toolbar.
    5. In the setup dialog box that pops up next, choose ‘Repair’ and select ok. Wait for setup to complete.
    6. Restart the computer if prompted.
    7. Now connect your phone to the PC. Driver installation should complete and PC/Ovi suite (hopefully) should detect your mobile properly now.
    Please THANK me by clicking on the ****WHITE STAR** ( Giving KUDOS) the big GREEN BOX to your LEFT .
    It will help me to serve you better !!!!!
    Thanking You

  • CachedRowSetImpl.acceptchanges(con) don't release the connection

    Hi all,
    i've have this problem using the CachedRowSetImpl tecnology.
    this is my code:
    CachedRowSet TargetTableCursor= new CachedRowSetImpl();
    ...I populate the cursor...
    ...I update the cursor
    ...I retrieve the connection con accros a poolconnection object
    ...I update to the Database with the following istructions
    TargetTableCursor.acceptChanges(con);
    con.close();
    at this point, the object con (the connection) it does not come destroyed.
    someone has an idea about this?
    thanks
    Emiliano

    Hi,
    It looks like you have some "wrong" concepts.
    First you say that:
    <b>Now in WS1, there is no schema</b>
    later on you are telling
    <b>have then check the command
    select * from SAPBOS.SVERS and it worked.</b>
    So, do you have a schema or don't you?
    Let me try to understand what you have done, for your description
    1) you have a system called BOS. On this system you have a schema called SAPBOS.
    2) you did a system copy from BOS to W1S. Guessing -> You did a restore from a BOS
    Now your SAPW1S has "dissapeared"
    am I understandin it properly?
    If so, you should think a little.
    You have restored a backup from BOS ( DB name BOS, SCHEMA BOS, tablespace names PSAPBOS ) into W1S
    Restoring a backup will not change the schema name ( AFAIK, there is no simple way of doing so )
    Restoring a backup will not change the tablespaces names ( in Oracle 10g you can do this, but has to be done manually )
    Restoring the backup will not change the DB name. The System copy procedure ask you to create a script that will perform this last change.
    So, at the end of the process you have a DB called W1S, with a schema called SAPBOS and tablespaces called PSAPBOS.
    As mentioned before there is no simple way of changing the schema name.
    If you <b>need/want/desire</b> to do so then you cannot use BACKUP/RESTORE for system copies. You must use the R3Load method ( take all data out of the DB and then take all the data in on the new system )

  • Does importing my photos using the connection kit import in full resolution.

    I have been using the connection kit to import my photos. I was wondering if it imports them thin full resolution?

    Yes. You can reconfirm it with apps like Exif Wizard-Pro
    http://i1224.photobucket.com/albums/ee374/Diavonex/e6ac61de.jpg

  • What does this mean?? "The connection to the host was unexpectedly lost."

    i get this 95% of the time i try to login:
    The connection to the host was unexpectedly lost.
    it then closes
    i go thru AIM
    _*someone please help*_
    Message was edited by: migueliguel
    Message was edited by: migueliguel

    Hi
    Try logging on to AIM on port 443 rather than port 5190.
    Go to IChat in the menu bar > Preferences > Accounts.
    Log out of AIM and then use the Server Settings tab
    Set the port to 443.
    Log back in again.
    Tony

  • EJB3 : suspend JTA transaction does not release the connection in the XA DS

    Hi all,
    I did a test and after suspending a JTA transaction I note that in the xa datasource the activeconnection = 1.
    So is it normal because I was thinking that when I suspend the transaction the teh connection is released and then after a transaction resume I could continue the transaction with another connection of the xa datasource ?
    Thank you for all..
    Christophe.

    It's a long time ago, but did you ever solve this problem?
    I'm having the same issue with OSB writing to a WLS8.1 JMS queue.
    I have a development OSB server which works fine.
    Pete

  • CUCM unexpectedly release the connect

    Can anyboydy give a hint ?
    I have an Avaya - Cisco 2901 -CUCM H323 connection.
    If i ring from outside to local phone then call dropped after 5 sec. In the h225 log i see following sequence :
    (VG -> CUCM)        SETUP
    (VG -> CUCM)        CALL_PROC
    (VG <- CUCM)        ALERTING
    (VG <- CUCM)        NOTIFY
    (VG <- CUCM)        CONNECT
    (VG <- CUCM)        NOTIFY
    (5 sec wait)
    (VG <- CUCM)        RELEASE
    If I call from local  to outside then connection established and called party picks up the phone, but calling party doesn't get any sign of that.
    What can cause the problem ?

    Can anyboydy give a hint ?
    I have an Avaya - Cisco 2901 -CUCM H323 connection.
    If i ring from outside to local phone then call dropped after 5 sec. In the h225 log i see following sequence :
    (VG -> CUCM)        SETUP
    (VG -> CUCM)        CALL_PROC
    (VG <- CUCM)        ALERTING
    (VG <- CUCM)        NOTIFY
    (VG <- CUCM)        CONNECT
    (VG <- CUCM)        NOTIFY
    (5 sec wait)
    (VG <- CUCM)        RELEASE
    If I call from local  to outside then connection established and called party picks up the phone, but calling party doesn't get any sign of that.
    What can cause the problem ?

  • What does transaction iView do in the background?

    Hi,
    I see, it is based on the component "com.sap.portal.appintegrator.sap.Transaction".
    In essence I need to create a transaction iView from a portal component. What is the procedure to do that?
    Any examples on that would be helpful.
    Regards,
    Megha.

    Hi Megha,
    A Transaction iView is based on the Application Integrator component.
    For more information, see:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/the application integrator in ep 6.0
    (a zip file)
    And:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/de95e490-0201-0010-b390-f0f23a95e2b8
    (a pdf file)
    As for launching a Transaction via url, see:
    How to launch SAP transaction & pass parameters via URL
    Hope that helps,
    Yoav.

  • Does Apple will also release Lion OS downloadable in CD's?

    If so when will it be?

    "...later this August, Lion will be made available on a USB thumb drive through the Apple Store® (www.apple.com) for $69 (US)."
    http://www.apple.com/pr/library/2011/07/20Mac-OS-X-Lion-Available-Today-From-the -Mac-App-Store.html
    MotionMan

Maybe you are looking for