PreparedStatement wrapper behavior when SQLException is thrown

Environment:
weblogic8.1 sp3
IBM db2 (universal) type 4 driver
StatementCacheSize=0
Use case:
The code uses a PreparedStatement to insert let's say 60000 rows in a loop.
The method used is executeUpdate() inside the loop. Some insertion
attempts let's say 20000 are throwing duplicate primary key exception,
which is fine. When such exception occurs it is skipped and the code
continues with the next iteration inside the loop.
Problem:
Only one PreparedStatement is used in the code. Apparently the weblogic
wrapper around the PreparedStatement is using a new wrapped
PreparedStatement every time that a SQLException (in our case duplicate
primary key) occurs when calling executeUpdate(). The result is that
after ~7000 iterations in the loop (it's depend how much resources the
database was allocated for the current session) the database throws another
SQLException saying that there are no more memory resources for this
session.
Consequence:
Memory consumption is extremely high – the loop cannot finish.
I am guessing here: Every iteration in the loop that throws a SQLException
causes the wrapper to use a new PreparedStatement which means execution
of connection.prepareStatement() again – unnecessary roundtrip to the
database.
Note:
The code was tested inside the weblogic container with different
database MySQL - same behavior.
The code work without any problems outside of the weblogic container and
it uses only one object of type PreparedStatement.
Thanks,
Assen

Assen Sotirov wrote:
The code executes inside a POJO. Thus we can execute it as a standalone application or in EJB Session with CMP. There are only two differences:
1) how a Connection is obtained - directly using the JDBC driver (standalone) or getting it from a DataSource (inside weblogic)
2) how commit/rollback is done - directly using the Connection (standalone) or declare it in xml descriptor (inside weblogic)
Connection pool definition:
<JDBCConnectionPool
Name="upsnd3db"
DriverName="com.ibm.db2.jcc.DB2Driver"
MaxCapacity="4"
Password="{3DES}+BLABLABLABLABLA=="
Properties="user=BLABLA"
StatementCacheSize="0"
StatementCacheType="LRU"
Targets="pcs"
URL="jdbc:db2://BLABLABLABLABLA:BLA/BLA"/>
Turning the jdbc loggin on produces (IBM driver has rather verbose output, so I will truncate it):
[Connection@b0c5a] prepareStatement (insert into ...) called
[Connection@b0c5a] prepareStatement () returned PreparedStatement@b9979b
[PreparedStatement@b9979b] setString (1, 00037NHD1 ) called
[PreparedStatement@b9979b] setDate (2, 2005-09-01) called
[PreparedStatement@b9979b] setTimestamp (9, 2005-09-15 15:26:12.093) called
[PreparedStatement@b9979b] executeUpdate () called
com.ibm.db2.jcc.c.SqlException
....at com.ibm.db2.jcc.c.cl.d(cl.java:1039)
....at com.ibm.db2.jcc.c.cm.executeUpdate(cm.java:311)
....at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:115)
BEGIN TRACE_DIAGNOSTICS
com.ibm.db2.jcc.c.SqlException:
DB2 SQL error:
SQLCODE: -803,
SQLSTATE: 23505,
[Connection@b0c5a] prepareStatement (insert into ...) called
[Connection@b0c5a] prepareStatement () returned PreparedStatement@9830bc
[PreparedStatement@9830bc] setString (1, 000759BA7 ) called
Notice that the StatementCacheSize is 0 and also a new PreparedStatement is allocated and used after the SQLException is thrown. This contradict to your statement:
I see, and I see something in the code. I have attached a
patch to tey (get it ahead of the weblogic.jar in the
server classspath).
thanks
Joe
I am saying that for a zero-cache setup, the serverside statement wrapper
won't change in any loop, and neither will the DBMS driver statement it
wraps, regardless of any exceptions during execute() calls.Thanks,
Assen

Similar Messages

  • Rollback when SQLException is thrown

    Hi all,
    If the set autocommit is false and if any statement throws SQLException then what will happen to that transaction. Will it rollback the entire transaction ?. Before returning the connection to pool do I have to set autocommit to true ? By default autocommit is true.
    rgds
    Antony Paul

    An SQLException will not rollback your transaction. You don't have to set autocommit to true before returning the connection, but it's generally a good idea to do it. What you have to do (and you'll have to use a finally block to make sure that it happens) is to either commit or rollback the transaction.
    Alin.

  • Detecting when exception was thrown using custom class loader

    Hello all,
    I would like to implement the solution described here - http://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java - that uses custom class loader in order to detect when an Exeption thrown somewhere in the JVM hosting my app, please note that exceptions might be thrown from 3rd party jars the app is using. So, thanks to help I got from another post, I've managed to code the custom class loader. My question is how can the class loader wrap the original exception, as the methods in ClassLoader deals with classes, not instances. So where should I set the original exception?
    Thanks!
    Edited by: user9355666 on Sep 28, 2010 10:48 PM

    user9355666 wrote:
    I think I'm missing something fundumental, forgive me for being slow...
    This is what I did so far. For the exception wrapper I made a simple class extens Exception that recieve Exception in its ctor and store it. I also subclassed ClassLoader and override its loadClass(). I've registered it as the system classloader. My thinking was to check in that point that if the requested class is instance of Exception and if yes, returning my wrapper class wrapping this exception. But, since loadClass() return class, how can I set in the wrapper the original exception?
    In addition, let's say 2 different places in the code throws NPE, to my understanding the classloader will load NPE only once, so how throwing the NPE in the second time can be detected?you are missing a key point. you should creating a custom implementation of the NPE class which hooks into your detection code in its constructor. from that point forward, anytime any NPE (which is your custom class) is constructed, you can detect it.

  • How do you turn off the auto select behavior when working with shape layers?

    How do you turn off the auto select behavior when working with shape layers?
    I am using either of the path selection tools to select only some of the paths on the layer. I have the proper layer targeted. I have the selection too auto select option turned off.
    If another layer has a path in that area, that layer becomes auto targeted and I get the wrong path. Turning off the layer is the only way to avoid this but then I have to  turn on the layer back on between making my selection and transforming to use the other layer as guide. Is there any way to stop this auto select? Locking the other layer does not stop the auto select, just prevents editing.

    As far as i know the move tool options don't have any effect on the path selection tools.
    You might try clicking on one of the path points or on the path itself with one of path selection tools and if you want to select multiple points
    you can shift click with the Direct Selection Tool or Alt click to select the entire path.
    more path shortcuts:
    http://help.adobe.com/en_US/photoshop/cs/using/WSDA7A5830-33A2-4fde-AD86-AD9873DF9FB7a.htm l
    http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7391a.h tml

  • Strange behavior when I try to match a mpeg2 video with the menu size image

    hello all,
    got a strange behavior when I try to match a mpeg2 video with the menu size image,
    menu size is 1920 x 1080 (photoshop file)
    mpeg2 video 1920 x 1080 (1second 19 frames)
    the idea is to go from the menu link to the next sub menu with a video as transition, using the same image on the video as the menu and then zooming in (in my case through a door) to end up after the zoom in the next level menu.
    I try to achieve a smooth change from the first play menu picture to the video image into the next level menu picture,
    everything works good but when I watch it on the preview mode on the left and right side of the video it shows a black bar at least 15 to 25 pixel wide, that means the video image appears smaller and it causes a little jump what is preety disturbing and can not be sold as a professional work.
    why encore treats the video size and picture differently?
    it's gratful appreciated if somebody who got experience in a transition I mentioned obove posting any solution,
    thankl you all

    Hi all
    I'm having a very similar problem with Encore. My menu items are distorting (a minor but infuriating squashing top and bottom) when previewed.
    Using Encore,PS,AE CS4
    DVD format SD PAL DV widescreen
    I created 3 menu frameworks and 3 video transistions to link them in AE. On the final frame of each transistion in AE I saved the frame with Composition>Save Frame to> Photoshop Layers. In PS i added the button functionality and saved.
    In Encore I use Dynamic link to import AE transistions as timelines and imported each PS menu twice, once as "menu" and once as an asset.
    When I link the timeline transistions to the menu and preview at the point the menu begins the whole image is squashed. When the next transistion is activated the image returns to its original size.
    Thinking it was the use of PS that was causing the menus to distort I used the menu asset directly in the time line. Obviously no menu functionality but also no distortion. The AE transistion flowed straight into the "menu" just as I expected.
    In the properties panel the menu Aspect Ratio 16:9
    The AE transistions PAR is SD PALwidescreen 1.4587.
    I did try the Blu Ray suggestion above but the same distortion was apparent.
    Any suggestions short of squashing the video to match the menu would be welcomed.
    Thanks

  • Behavior when typing 'Enter' in h:inputText

    I am seeing the following behavior:
    When a user types the 'Enter' key when a h:inputText has focus, the page seems to behave as if the user clicked the first button added to the page. (In my case this is a 'Cancel' button that clears data and causes navigation to another page. Many users are used to hitting 'Enter' when the have finished inputting text - so the 'Cancel' behavior would not be a pleasant suprise.)
    My questions are:
    1) Is this supposed to happen when 'Enter' is typed in a h:inputText?
    2) Can I change this and how?
    3) I would like it so hitting 'Enter' does nothing (better would be to move to the next h:inputText) Can this be done and how?
    Any info regarding these specific questions or generally how key interactions work with jsf/Creator would be appreciated.

    You can do this using JavaScript:
    Specify the onkeypress of the inputText like this:
                                    <h:inputText binding="#{Page1.tfSearchString}" id="tfSearchString" onkeypress="return onEnterSubmit(event);" value="*" valueChangeListener="#{Page1.tfSearchString_processValueChange}"/>The in the head part of your page, add the following javascript:
                    var ie4 = false;
                    if(document.all) {
                        ie4 = true;
                    function onEnterSubmit(event) {
                        if (ie4) {
                            if (window.event && window.event.keyCode == 13) {
                                document.forms['form1']['form1:btnRefresh'].focus();
                                document.forms['form1']['form1:btnRefresh'].click();
                                return false;
                            else
                                return true;
                        else
                            if (event && event.which == 13)
                                document.forms['form1']['form1:btnRefresh'].click();
                            else
                                return true;
                    }This assumes you have btnRefresh as the name of the submit button, and you want it clicked on enter key press. Else just comment out the part with the .click()/focus() to prevent any action on Enter key press.
    Also, you can focus on any other textField in the page with the enter by replacing the click()/focus lines() with document.forms['form1']['form1:tfName'].focus()

  • Question about the CSS behavior when using layer 3 sticky and sticky table

    Hi everyone,
    I have a question about the CSS behavior when using layer 3 sticky and sticky table is full.
    If I configure layer 3 sticky and specify the inactivity timeout as below, how does the CSS
    handle subsequent needed sticky requests ?
    advanced-balance sticky-srcip
    sticky-inact-timeout 30
    CSS document says that
    Note:
    If you use the sticky-inact-timeout command to specify the inactivity timeout
    period on a sticky connection, when the sticky table becomes full and none of
    the entries have expired from the sticky table, the CSS rejects subsequent
    needed sticky requests.
    My question is what is the next reaction by doing the CSS if the CSS is in the
    following condition:
    when the sticky table becomes full and none of the entries have expired from
    the sticky table, the CSS rejects subsequent needed sticky requests
    Does CSS just rejects/drops subsequent needed sticky requests ?
    or
    Does CSS does not stick subsequence requests to particular service but CSS forward
    subsequence requests with round-robin basis ? which means if the sticky table is full,
    the CSS just works round-robin load balancing fashion for subsequence requests ?
    Your information would be appreciated.
    Best regards,

    Hello,
    There is a good document explaining this on Cisco web site
    http://www.cisco.com/en/US/products/hw/contnetw/ps789/products_tech_note09186a0080094b4b.shtml
    It depends if the sticky-inact-timeout is used or not. If not, it's FIFO (the oldest entry in the sticky table is removed). If yes, the CSS will reject the next sticky request.
    Rgds,
    Gaetan
    Rgds
    Gaetan

  • Odd behavior when duplicating pages

    I have run into some odd behavior when duplicating pages.
    First I spent many hours trying to acomplish a double trigger effect in which the last trigger opened a large image in a pop up window. Thanks to help from agm 123 and Sachin Hasija  see the posts here: http://forums.adobe.com/message/5186239#5186239
    And the result here: http://ljusa.businesscatalyst.com/stockholm--1.html
    I had to do a number of work arounds, but succeeded and will help anyone interested to reproduce this type of effect.
    My next step was to recreate this effect for another 50 pages. The best way I have found is to duplicate the first page. This is where it gets weird.
    When I create a duplicate and replace the images in the newly created pages (done by changing the fill to the new image) with different ones and save it the changes are effected on the original page, not the clone. No big problem, just switch the names and continue.
    The next problem that occurs is that when I go to make further copies a variety of odd behaviors creep in. The biggest problem is a repositioning or resizing of photo frames/containers. The images do not change, just move as the frame resizes. When I try to resize the frame it snaps back to it's larger new size. This is a phenomenon that I have seen in other instances in work with lightboxes and slideshows. It seems that some other unseen element has jumped into the frame with the original frame.
    The method I have used to create these pages is as described in the post at: http://forums.adobe.com/message/5186239#5186239
    It involves creating a blank composition widget and then placing a composition lightbox widget trigger into the blank hero.
    I have already invested more time than I should have on this and would like to keep it simple, yet as I have 50 pages to go I could start from scratch if someone has a better method of doing this.
    Suggestions?

    Just an update.
    I haven't seen the naming problem with duoplicates reoccur. I am however still stuggling with duplicates.
    I have a page with 5 image frames linked to images which in turn trigger a lightbox. When I create a duplicate of a page there is always at least one of my image frames that moves and or a link to an image that is dead. The only recourse I have had is to recreate one of the lifgtboxes for each new page I create. With all the formatting this is time consuming.
    I have tried copying and pasting the entire page into a blank page, but then there are even more problems.
    I have also tried to save my lightbox as a graphic style, but that dooesn't seem to work either.
    Please Help! I've got at least 45 more of these pages to replicate1

  • Strange Mail Behavior when cicking reply to

    I am having a very different but very strange behavior when in mail 5.2 I click on reply or forward in my menu bar a new mail window opens up and quickly moves off to the right of the screen and disappears laving my inbox. I cannot find where they are going and the only way I can respond is open the mail in a new window. This is weird I have been using mail forever and never seen this before?
    any suggestions???
    mac os 10.7.4
    Thanks for any suggestions

    So Mail doesn’t really crash (i.e. quit unexpectedly). Rather, it freezes (i.e. becomes unresponsive), right?
    What type of mail account is this (POP, IMAP, .Mac)?
    Verify/repair the startup disk (not just permissions), as described here:
    The Repair functions of Disk Utility: what's it all about?
    Go to Apple Menu > System Preferences > Network, choose Network Port Configurations from the Show popup menu, and make sure that the configuration used to connect to Internet appears at the top of the list.
    Try disabling Search .Mac For Certificates in Keychain Access > Preferences if it’s enabled. Take a look at the following articles for an explanation of why this could be the problem:
    http://www.hawkwings.net/2006/07/18/apple-mail-phones-home-too/
    http://www.macgeekery.com/tips/mailapp_doesnt_phone_homeeither/

  • PreparedStatement vs Statement - When executing only once

    Are there any performance implications in using PreparedStatement vs
    Statement when you are executing the SQL only once? I am talking about all
    kinds of SQL (Select, Update, Insert and Delete). If PrepatedStatement is
    used, I would expect some overhead in setting values for different columns
    separately and precompliling. Is that overhead significant enough to
    degrade performance? If we execute statement only once, I do not expect to
    any gain on performance.
    I would appreciate any comments.
    Sarat

    It also depends on the database/driver combination,several database can be
    configured to maintain a prepared statement cache at the DB level (I have
    never done it myself, but I know people who has done this. Lately I use
    mostly Oracle, for which I should not be configured an expert :)).
    Also the weblogic's prepared statement cache only caches first so many
    statements. If you have used them all up at the startup you are out of luck.
    I know you already knew that, but may be helpful to the original poster.
    .raja
    "Cameron Purdy" <[email protected]> wrote in message
    news:[email protected]..
    BTW - there is a case where prepped stmts are faster -- when they arecached
    by Weblogic's jdbc wrappers. So my previous answer can be wrong.
    Peace,
    Cameron Purdy
    Tangosol Inc.
    << Tangosol Server: How Weblogic applications are customized >>
    << Download now from http://www.tangosol.com/download.jsp >>
    "sarat" <[email protected]> wrote in message
    news:3b715901$[email protected]..
    Are there any performance implications in using PreparedStatement vs
    Statement when you are executing the SQL only once? I am talking aboutall
    kinds of SQL (Select, Update, Insert and Delete). If PrepatedStatement
    is
    used, I would expect some overhead in setting values for differentcolumns
    separately and precompliling. Is that overhead significant enough to
    degrade performance? If we execute statement only once, I do not expectto
    any gain on performance.
    I would appreciate any comments.
    Sarat

  • Strange behavior when performing query

    Hi all,
    I'm getting some odd behavior when doing different kinds of queries and am hoping someone here can help out. I have a database with continuously updated PDML data (http://www.nbee.org/doku.php?id=netpdl:pdml_specification). I am opening anf querying the database from a seperate application. This appears to work fine for certain types of queries, and fails for other types with error messages that don't seem relevant. Specifically, some queries that use the attribute axis as the last leaf seem to get fouled up. Here are some example queries and the results I get:
    First some queries that work:
    Query: "string(collection()[1]/packet[1]/proto[1]/field[1]/@size)"
    Result:
    A valid number
    Query: "collection()//proto[@name='geninfo']/field[@name='len']"
    Result:
    <field name="len" pos="0" show="64" showname="Packet Length" value="40" size="64"/>
    <field name="len" pos="0" show="64" showname="Packet Length" value="40" size="64"/>
    <field name="len" pos="0" show="64" showname="Packet Length" value="40" size="64"/>
    Now some queries that don't work:
    Query: "collection()//packet/proto/field/@size"
    Result:
    Output to stdout - "Transaction specified for a non-transactional database"
    and an Exception with message - "Error: Invalid argument"
    Query: "collection()//proto[@name='geninfo']/field[@name='len']/@name" (notice it's almost identical to above working query except with @name)
    Result:
    Same as above, an stdout about transactions and an exception about invalid arguments
    What I find most interesting is that both errors (the one printed to stdout and the one I get in my exception) don't seem to have anything to do with the problem. I know the transactional stuff isn't messed up because the exact same code works for certain queries. I'm not sure about the "Error: Invalid argument" exception, but it's not very helpful by itself. I'm using the Java library and DBXML version 2.4.16. Anyone have any ideas what's going on?
    Thanks,
    Dave

    As a follow-up, it appears that I just needed to wrap my attributes in the XPath string() function. For example "collection()//packet/proto/field/@size" does not work while "collection()//packet/proto/field/string(@size)" works fine.
    I'm still not sure why it's spitting out an error message to stdout about transactions not being enabled when the only real error is with the query, but at least it's working now.

  • [svn:cairngorm3:] 21050: Popup: The default behavior when an Event. CLOSE is dispatched through the popup component should be preventable

    Revision: 21050
    Revision: 21050
    Author:   [email protected]
    Date:     2011-04-09 16:22:58 -0700 (Sat, 09 Apr 2011)
    Log Message:
    Popup: The default behavior when an Event.CLOSE is dispatched through the popup component should be preventable
    https://bugs.adobe.com/jira/browse/CGM-59
    Popup: The write-only behaviors property can not be used with states
    https://bugs.adobe.com/jira/browse/CGM-55
    Ticket Links:
        http://bugs.adobe.com/jira/browse/CGM-59
        http://bugs.adobe.com/jira/browse/CGM-55
    Modified Paths:
        cairngorm3/trunk/libraries/Popup/src/com/adobe/cairngorm/popup/PopUpBase.as
        cairngorm3/trunk/libraries/Popup/test/com/adobe/cairngorm/popup/PopUpBaseTest.as
        cairngorm3/trunk/libraries/PopupTest/.actionScriptProperties
    Added Paths:
        cairngorm3/trunk/libraries/PopupTest/html-template/
        cairngorm3/trunk/libraries/PopupTest/html-template/index.template.html
        cairngorm3/trunk/libraries/PopupTest/html-template/playerProductInstall.swf
        cairngorm3/trunk/libraries/PopupTest/html-template/swfobject.js

    Hi Shweta,
    as i discussed with you to update the script code
    <html><script> function closeWindow( ){       top.close( );     }                  </script><body><form> The application was logged off successfully. <br><input type="button" value="close window" onclick="closeWindow( );" /></ form></body></html>
    in sicf transaction for your component.
    it will work (close the window).
    dont forget to give me points
    all the best...
    Rgds,
    Mahesh.Gattu

  • Different behavior when running in Eclipse and on Tomcat

    I am having a problem because the program that I wrote, tested, and work fine on Eclipse doesn't have the same behavior when I convert it to a Web Service and called by a client.
    I have not this strange behavior. See this code:
    NamedNodeMap attrs = node.getAttributes();
    System.out.println(attrs.getNamedItem("performance"));When I run it on exist I got something like this:
    org.apache.crimson.tree.AttributeNode1@11bed71which should be correct since attrs.getNamedItem() return a Node.
    But! When I run it as a web service on Axis hosted on Tomcat I got
    performance="3758.0"???!!!
    Also, when I do something like
    System.out.println(node)In Eclipse I got the whole XML file like this:
    <root><sequence name="main" performance="3591.5" cost="63.5" reliability="4144965.2" availability="0.9863115" integrity="1.0" security="128.0">
              <switch name="switch-1" performance="3591.5" cost="63.5" reliability="4144965.2" availability="0.9863115" integrity="1.0" security="128.0">
                   <case condition="bpws:getVariableData('i') = 0" performance="3425.0" cost="77.0" reliability="1.0" availability="1.0" integrity="1.0" security="128.0">
                        <invoke name="invoke-2" partnerLink="HotelBooking" portType="nsxml2:HotelBooking" operation="searchHotel" inputVariable="searchHotelParam" outputVariable="searchHotelResult" serviceKey="95EDCDE0-46F6-11DA-BEB0-90CACF0DCD6A" />
                   </case>
                   <otherwise performance="3758.0" cost="50.0" reliability="8289929.5" availability="0.972623" integrity="1.0" security="128.0">
                        <while name="while-1" condition="bpws:getVariableData('i') > 0" performance="3758.0" cost="50.0" reliability="8289929.5" availability="0.972623" integrity="1.0" security="128.0">
                             <sequence performance="3758.0" cost="50.0" reliability="8289929.5" availability="0.972623" integrity="1.0" security="128.0">
                                  <invoke name="invoke-1" partnerLink="FlightBooking" portType="nsxml0:FlightBooking" operation="searchFlight" inputVariable="searchFlightParam" outputVariable="searchFlightResult" serviceKey="AD5A1880-46EC-11DA-B399-97115D85E15E" />
                             </sequence>
                        </while>
                   </otherwise>
              </switch>
         </sequence></root>but on Axis I got:
    [root: null]I'm confused. I think it might be because of the different version of the library between eclipse environment and axis environment. But the problem is, I can't figure out what JAR should I change. Can you give me a clue??

    DOM doesn't specify what the toString() method of Node etc. should return. So each implementation of DOM chooses something that seems reasonable to the implementers. If this isn't suitable for you then don't use the toString() method. (That's what System.out.println calls when you pass it an Object, in case you didn't know.)

  • Erratic power behavior when wall charging

    Whenever I charge my iPad using the charging block and AC current, I like to turn the power off altogether, rather than just put the iPad into sleep mode.
    As soon as I plug it into the wall, the iPad power comes back on. When I go to shut it off again, sometimes it stays off, but sometimes it powers off and then back on after a few seconds.
    Is this normal behavior when wall charging?

    The ipad cannot charge white it is off. So therefore when you plug it into the wall it turns on to charge and turn it off the ipad knows the power is there but needs to be on to keep it so it turns on..
    You are actually damaging your ipad when you turn it off while charging. The reason the second time it stays off a little longer is because the ipad stopped connection until the next wave of electricity flows which is why it turns back on.

  • Issue about tracking behavior, when use tracker

    when using the tracking behavior, when whe choose to simply click on analyze and when to apply and use a tracker

    The link I provided is the user manual section about tracking.  It has the workflow for stabalizing.
    http://help.apple.com/motion/mac/5.0.5/#motn18190529
    The section on strategies to improve tracking is important, also.
    http://help.apple.com/motion/mac/5.0.5/#motn181912dc

Maybe you are looking for