How to close statement when calling in chain sequence

Hi all,
just have a look on below code:
java.sql.connection con =null;
//here getting connection
ResultSet rs= con.createStatement().executeQuery("sql");
its similer to chaining pattern. here I am having question,
with the line:
con.createStatement()
I am creating the statement and later using this object (which is implicit object as i m not having any futher reference of it, is it correct word which i used) i am executing query and getting result set object.
here statement object is implicit object.
is I need to close this object? As per me its too required and i can retrived statement object with the help of resultset object and can use close method.
but what does the java best pratice say? how they handle objects which are created in chain calling.
for example
//this.getPatternCode().getProperty().getName()
thanks,
Pax

In short : stop doing this, it's a bad idea.
You must always close all your resultsets, statements and connections._ Anyone who tells you anything different is wrong. End of story. Failure to properly close JDBC resources can lead to any number of problems including having your program crash and/or having the database crash.
So stop doing that.
There is only one correct practice and it is what is below.
Create the connection and keep a reference to it.
Create the statement (this can be a PreparedStatement or CallableStatement as well) using the connection and keep a reference to it (the statement).
Create the result set using the statement.
Process as needed.
Close the resultset in a finally block.
Close the statement in a finally block
Close the connection in a finally block.

Similar Messages

  • SPA 30x and 50x - show miss state when call was pickup

    Hello
    do you know, how to show on display miss state (softkey miss) when call was pickup in pickup group.
    My IP phone is SPA 303 and 502, and 922 but SPA 922 is showing miss state well.
    Server is Asteriks.
    Marek

    Call completed elsewhere has not been missed, so SPA922 is on the wrong side ...
    If the line is declared as shared AND call is CANCELed with
    Reason: SIP;cause=200;text="Call completed elsewhere"
    then no missed call is logged.
    I'm not sure if you can configure Asterisk not to use this Reason in such particular case. If I remember correctly, there is and option of Dial() Application for it ...
    Of course, unless you have User->Supplementary Services->Log Missed Calls for extension in question set to "Yes" no missed calls are logged at all.
    Rate useful advices and/or mark answer as "correct". It will help others to found solutions.

  • How to transfer username when calling web service from PI?

    Hi
    I have a scenario where a front end application is calling a web service exposed by PI 7.11 and PI is forwarding the call to the backend web service. That is, a SOAP sender adapter and a soap receiver adapter.
    Now, I would like to transfer the username, which the PI exposed web service is called with, to the backend web service.
    I previously did this by using a UDF where I picked up the username like this and mapped the username to a field in the request message when calling the backend web service:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", "SRemoteUser");
    String WSuser = conf.get(key);
    return WSuser;
    However, I would like to avoid this method and in stead e.g. use either a query string like http://xxxxx:6571/ISBWS/soap/ISBCore?username=mikael or maybe transfer the username in the http header in some way.
    So my question is: what are my options and how do I set it up?
    BR MIkael

    Apparenty sending user name details in query string  is not best practice in webservice. Thats why WSDL does not cover user credentials inside. Webservice deals with message level security , transport level security, encryption , certificate authentication , username token etc
    If you want to use http query string in the soap receiver target url try as below and see how that helps... somthing as below..
    example:  http://host:port/jsppage?userid=test  or use  xslt mapping or java mapping create soap header as you want and specify username over there.

  • How to fill data when call function of sap standard script form?

    Hi every experts,
    <Priority Normalized>
    In our system, when we log in 'FR', we can print purchase order in language Franch,in t_code:ME22N.  And when logging in 'EN', we can print it in language English, in ME22N. The English form is just only translated from Franch, with all same structure and frame.  The form is done by script form.
    And when logging in 'ZH', we create a new program, calling function smartform, instead of translating from EN language. Because of different structure and frame, I don't know the way to write script, so  I print puchase order by smartform, when logging in 'ZH'.
    But I have a new issue. Our MM module consultant needs me to print Chinese form if one condition, print English form in other condition.
    So I have no idea to solve it. Because in my program, I get data to fill smartform and call function of smartform. And I don't know how to get data to fill script form. I only know the function name, 'OPEN_FORM' 'WRITE_FORM' 'CLOSE_FORM'.....
    If I only call the several functions, I will get only frame without no data. So who can tell me how to do????
    <Urgency downgraded>
    Edited by: Suhas Saha on Jul 26, 2011 3:34 PM
    Edited by: Vinod Kumar on Jul 26, 2011 4:09 PM

    Hi,
    Normally if we look in NACE transaction, you can see that upto five different FORMS can be assigned to a single output type . i.e. for each form there will be a seperate routine through which it gets called. But it all start from the first form only.
    so you need to write your code in the ENTRY of the first form and if it does not satisfy do not go for processing of it but just exit of that form ENTRY. so that it will take you to next form.
    hope this helps.
    Thanks,
    Venkatesh

  • How to bypass prompt when calling storeUserConfig() ?

    Hi,
    In WLST, is it possible to bypass/skip the prompt you get when you call storeUserConfig() ? You have to answer y or n to allow/disallow the creation of the user config and key files.
    Thomas Isaksen

    Thomas, I've not tried it myself, but a posting on this forum from a few years ago had an answer for WLS 9.1:
    Re: How to specify response with storeUserConfig in WLST ?
    -Dweblogic.management.confirmKeyfileCreation=true-steve-

  • How to close sidebar when reading mail

    when reading mail in iPad i am unable to close the sidebar which shows emails accounts and inbox.

    This is to "art3410" --
    That's exactly how it was designed to work. If you want to suggest a different method to Apple, then do so here ...
    Product Feedback
    https://www.apple.com/feedback/

  • How to hide URL when calling Reports from Forms 10g.

    Hi ,
    When end user runs a report through a form then report output is displayed and following type of URL is also generated on address bar of browser: http://server:7778/reports/rwservlet/getjobid22243?server=rep_servername_appsrv
    Can we hide this URL so that the user cant change the JOB_ID and get access to other previous reports.
    Thanks & Regards,
    NL

    Actually, there are several options including the one already offered above. Here are a few more:
    1. If you are using 10.1.2.3 and a newer JRE on the client (e.g. 1.6.0_10 or newer), you could use java script to open the report. This will not be a perfect solution because it may not work if using a non-IE browser or if java scripting is disabled. Refer to MyOracleSupport Article 265863.1 for more information.
    EXAMPLE:
    WEB.SHOW_DOCUMENT ('javascript:void(window.open("http://www.oracle.com","","location=no,toolbar=no,menubar=no,"));self.close()','_blank');Replace the url in the above example with the call to your report.
    2. Set the age of the cache to a very short value so that it is only available long enough to be viewed by the user who created it. In other words, when setting the reports properties in your Forms code, include the Reports "others" parameter with TOLERANCE=1
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'TOLERANCE=1');This will cause the cache (on the server) to live for only one minute then be deleted. Refer to the Report Deployment Guide for more information.
    3. Upgrade to Fusion Middleware (Forms/Reports) 11. In version 11, the Reports jobid can be randomized. See section 18.8.2 of the Reports 11 Deployment Guide
    http://download.oracle.com/docs/cd/E14571_01/bi.1111/b32121/toc.htm

  • How to output HTML when called from a browser

    We are trying to replace a small web app with a bpel app so it has to return HTML. I keep getting XML of the HTML as output from this simple app. It doesn't interpret the html. The bpel uses a simple assign that puts an HTML string into the "body" message then passes it to the "reply".
    I have found out how to call this from the browser by changing "orabpel" in the url to "httpbinding" and then adding the "operation" onto the endpoint.
    from: http://server:7777/orabpel/default/ws1/1.0
      to: http://server:7777/httpbinding/default/ws1/processIs it possible to output html back to the browser and have the bpel look like a web page? Setting the mimetype of the output message type to "text/html" seems to have no effect at all.
    Here is my wsdl:
    <?xml version="1.0"?>
    <definitions name="HTTPGetService"
                 targetNamespace="http://services.otn.com"
                 xmlns:tns="http://services.otn.com"
                 xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                 xmlns="http://schemas.xmlsoap.org/wsdl/"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
                 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
        <message name="HTTPGetServiceRequestMessage">
            <part name="Region" type="xsd:string"/>
            <part name="EffectiveDate" type="xsd:string"/>
            <part name="EndDate" type="xsd:string"/>
            <part name="acc1" type="xsd:string"/>
            <part name="acc2" type="xsd:string"/>
        </message>
        <message name="HTTPGetServiceResponseMessage">
            <part name="body" type="xsd:string"/>
        </message>
        <!-- portType implemented by the HTTPGetService BPEL process -->
        <portType name="HTTPGetService">
            <operation name="process">
                <input message="tns:HTTPGetServiceRequestMessage"/>
                <output message="tns:HTTPGetServiceResponseMessage"/>
            </operation>
        </portType>
        <binding name="HTTPGet" type="tns:HTTPGetService">
            <http:binding verb="GET"/>
            <operation name="process">
                <http:operation location="/process"/>
                <input>
                    <http:urlEncoded/>
                </input>
                <output>
                    <http:urlEncoded/>
                    <mime:content type="text/html" part="body"/>
                </output>
            </operation>
        </binding>

    Hi,
    Open up admin console. Expand "Servers" node to view servers in domain.
    Right click on a server (or select Logging/ General tab) and select "view
    server log".
    Regards,
    Jon

  • Package is invalid state when called in Trigger

    Hi All,
    We have a trigger in which we are calling procedure(which is created in some package). Every time the trigger is called it returned an error
    'Package is in INVALID State".We tried to clean the app pool and that error went away but now it started coming again.
    Please help as we have been struggling hard for this .
    Database is ORA 10g.
    Please let me know if there are any other questions.
    Thanks in Advance !!!
    Regards

    My question is
    Why do you post 'My car doesn't work, please help me' instead of specifying exactly (with source code) what went wrong?
    Now you are asking people to rub up their broken crystal ball!
    Sybrand Bakker
    Senior Oracle DBA

  • How to close dialogbox when next thread starts?.

    Hello,
    For my application, I want to scan an table entries through SNMP connection.The entries are in MIB in a external device.
    So, when I press scan button, it will take some time to get the table entries from MIB thro' SNMP protocol.Heres the problem. Till to get datas, the screen get idel.
    So, I want to use a Dialog box that displays " you are in scanning mode.Please wait". and this dialog box automatically closed when the user get datas.
    How can i fix this problem?.
    please, if possible give me the prgram code examples.
    Thanks in advance.

    public interface ThreadStoppedListener{
    public void threadStopped();
    public class MyFrame extends JFrame implements ThreadStoppedListener{
       MyDialog dialog;
       private void startProcessing(){
           new Thread(new MyThread(this)).start();
           dialog = new ....;
           dialog.setVisible(true);
       public void threadStopped(){
          dialog.setVisible(false);
    public class MyThread implements Runnable{
       ThreadStoppedListener listener;
       public MyThread (ThreadStoppedListener listener){
             this.listener = listener;
      public void run(){
          // do work here
          // when work is done
          SwingUtilities.invokeLater(new Runnable(){
              public void run(){
                  listener.threadStopped();
          return;
    }Message was edited by:
    BaltimoreJohn

  • How to fill variables when calling a web template as a modal dialog

    Hi Experts,
    My scenario is as follow:
    I have a web template (application) A with an analysis item which has enabled the option for selecting single rows, in the rows I have the characteristic 0EMPLOYEE and a button for executing the commands OPEN_TEMPLATE_DIALOG and SET_TEMPLATE for calling web template B. In web template B I have a report with the variable zp_employee.
    The behavior I need is, if the user is selecting a row in the analysis item of template A, variable zp_employee in web application B should be filled from the selection. If there is no selection of a row, the variable screen should shows up.
    The general issue here, is how to feed one or more variables that "live" in wad B from a web item (analysis, input item, combo box, etc) in wad A.
    I guess it has to do with setting parameters in the URL with which wad B is called, may be coding a java script in web template B in the standard action "Action Before first display", but not sure
    thanks for any help

    Hi:
    Try that one in SPRO.
    here are steps if u need them.
    SPRO
    SAP Reference IMG
    From here, open tree:
    SAP Netweaver
    SAP Buss Info Warehouse
    Reporting Relevant Settings
    BEx Web
    Set Standard Web Templates.
    Here add for Adhoc analysis and others if needed.
    Ram Chamarty
    Message was edited by: Ram Chamarthy

  • How to establish connection when call is made to another cell phone

    hi all
    I want to know what code we use to establish connection when we call someone. which API we can use .
    please tell me because i m searching but not getting n i m in beginning position to work on j2me. please send me some hint
    teenu
    Message was edited by:
    teenu_java

    Hi,
    Actually I am confused abt wht you want.
    If you want to establish connection at the instant of calling :-
    The Voice call has the higher priority than Data call so u cant establish a connection at the instant when you are calling
    If you want method to establish a connection for call then
    you can try with platformRequest(url) of midp2
    Regards
    @rjun

  • How to handle spaces when calling javaw.exe or java.exe

    Hi guys, I'm in the process of releasing my application.
    My application need to make this system call on Windows.
    C:\Program Files\MySoftware\javaw.exe -jar C:\Program Files\MySoftware\myJar.jar C:\Program Files\MyDocs\MyArgumentFile
    this 'Program Files' for after the javaw.exe call: C:\Program Files\MySoftware\myJar.jar causes a problem because javaw.exe consider C:\Program as it's first argument and thus crash.
    I wonder what to do with this. I don't want to change it to C:\MySoftware since it looks unprofessional.
    A cup of Java, cheers

    yawmark wrote:
    I wonder what to do with this.Quotation marks.
    ~Right, every shell I can think of allows you to use quotation marks around a set of any characters that you want to be treated as one token. Note that this feature is a function of the shell you're using, not necessarily the system API. Also, many shells treat single quotes and double quotes differently, though they usually both accomplish the purpose of grouping what they contain into a single token.

  • How to avoid renders when cutting and pasting sequences to a new timeline?

    I am working on a 45 minute documentary in Final Cut Pro 7.0.3.
    The footage is 1080 24p and is being editing in a ProRes standard timeline (not the HQ version). I work on the documentary in chapters (separate sequences)...and then for rough cut outputs...cut and paste the chapters into a separate sequence timeline (also ProRes at the same frame rate).
    However, sometimes simple text titles, which didn't need rendering in the shorter chapter timeline, show up as redlines that need rendering in the longer timeline. Which I don't quite understand unless the process of copying and pasting severs the render links...but why should it do that?
    My timeline is toggled to SAFE RT in both chapter timelines and the overall project.
    Can anyone offer some advice on how I can get those chapters into a longer timeline without the redline bar showing up?
    Many thanks,
    John

    Hi John,
    Which I don't quite understand unless the process of copying and pasting severs the render links...but why should it do that?
    Well as you noted, the titles don't actually need rendering in your shorter sequence, hence there are no associated render files ie no link is being lost as there is nothing being linked to. Do you follow me? The issue is instead related to how many of these "realtime without rendering" titles that your system can track and handle, and that in turn is related to the amount of RAM in your system and how you have assigned that RAM allocation in FCP's *System Settings...* window > *Memory and Cache* tab. In the short sequence you have fewer titles and so FCP is managing them all in realtime, but in the longer master sequence it would seem apparent that the total number of titles exceeds that which your system can handle with all being in realtime, so the latter ones will require rendering.
    My timeline is toggled to SAFE RT in both chapter timelines and the overall project ... Can anyone offer some advice on how I can get those chapters into a longer timeline without the redline bar showing up?
    First, I'd ask if there is any specific reason you have set your sequences to Safe RT as opposed to the far more flexible Unlimited RT option?
    Second, as alluded to above, you should investigate your current Memory and Cache settings. If its at the 10% default, then try increasing your Still Cache a little (use trial and error, maybe 15% or 20% is enough) ... you should see that your system can handle more of text generator items without needing to render when you allocate more RAM to the task, but note that as you allocate more to RAM to your Still Cache then you are effectively decreasing the RAM available to the rest of FCP, eventually you will hit a tipping point so don't push the value too high.
    Hope it helps
    Andy

  • Invalid cursor state when trying to insert record

    Hi everyone!
    I'm using JDBC-ODBC bridge to connect to a mySql database, which works fine. Then I try to insert new records, but this only works for the first record in the table.
    When there is already a record in the table, I always get "[Microsoft][ODBC Driver Manager] Invalid cursor state" when calling the updateRow()-method of the result set.
    Here is my code:            // open db connection
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection conn = DriverManager.getConnection("jdbc:odbc:TTManager", "xxxx", "xxxx");
                // Prepare SQL statement
                java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                ResultSet result = stmt.executeQuery("SELECT * FROM Player");
                result.moveToInsertRow();Then all fields are filled in this manner:            result.updateString("Name", name);And finally the insertRow should be written to the db:            result.insertRow();But at this point it gives the mentioned error, including these messages:         at sun.jdbc.odbc.JdbcOdbcResultSet.setPos(JdbcOdbcResultSet.java:5272)
            at sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(JdbcOdbcResultSet.java:4132)Since I'm very unexperienced with Java, I guess (or hope^^) it's just some stupid beginner's mistake.
    Oh, almost forgot to mention: The new record's data doesn't violate any unique-constraints on the table, all fields are explicitely filled and all variable's data types are matching their according field types!
    Any help would be appreciated!
    reinski

    Ok, I needed to help myself and this is what I found out:
    If the table already contains records, it is not enough to doresult.moveToInsertRow();but I must beresult.last();
    result.moveToInsertRow();I didn't find any explanation and even the code examples from the Sun tutorial don't mention this, so I guess it's a bug occurring in my poor IT environment: DB server running mySQL 5.0.0-alpha on a P1-233-MMX w/ 64MB under WinNT4 (hey don't laugh!!^^).
    Maybe this information is of use to someone having similar problems...
    Greetings!
    reinski

Maybe you are looking for

  • Special characters into datagrid through the use of buttons

    Hi! I have a datagrid for word input, I'm trying to create a "special characters" panel, kind of like google's new "virtual keyboard" thing on google.com, so that the user can enter data into the datagrid cells using characters that aren't on their k

  • Open Transfer Orders in WM Cycle Count

    Hi experts: My client wants to implant cycle counting in WM, we are using MIBC for CC indicator analysis and LX26 to create inv. doc. The material master is ready with the CC indicators. But my client wants to know what open TO´s are already created

  • Importing word 2004 docs with tables into Pages

    I work in video production, and my clients send me shooting scrips as word documents formatted with tables. Needless to say, I was quick to discover that Pages doesn't really 'like' these documents. I can't keep asking my clients to reformat their do

  • How does Adobe Forms Central base their automated page breaks when distributing to a PDF form?

    OR How can I define those page breaks before Adobe Forms Central created the PDF. I have attempted to "insert" a page break within the form; however, when distributing this form to be created as a PDF, the PDF is still placing the auto-generated page

  • Not able to copy a program plz help

    hi experts i ill have to create a copy of program SAPMSM20 (transaction sm20) . when i am copying the program in the output it is hsowing some different output . or i can say in case of SAPMSM20 it is calling screen 300 but wen i copied it it is call