Difference between conn.close() and conn=null;

Hi All,
Can anybody please let me know the difference between conn.close()
and conn=null;
where conn is reference to Connection.
Thanks and Regards
-sunjavadeveloper

Thanks for your response.
Is there any other good approach to close() & then
null the Obj. can u give us your opinion.
          finally
            try{
                     if(dbconn != null)     dbconn.close();
                     if(stmt != null) stmt.close();
                     if(rs != null) rs.close();
                     if(con != null) con.close();
            catch (Exception e)
                   logger.fatal(e.getMessage(),e);
throw new Exception ("Exception -- Vendor.java --
a -- authenticate -- " + e.getMessage() );
               dbconn = null;
               rs = null;
               stmt=null;
               con = null;
Putting the close() calls in finally block is good, but having them in individual try/catch blocks is better. That way you can still try to close the connection if closing the statement throws an exception.
I don't bother setting them to null. GC is smart enough to know that they've gone out of scope. I don't think it helps.
%

Similar Messages

  • What's difference between JPanel.remove(); and JPanel = null

    nice day,
    how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null,
    1/ because if JPanel does not contain any static JComponents
    2/ or any reference to static objects,
    then works as well as JPanel.remove or JPanel = null,
    or what and why preferred to avoid some action (to avoid to remove or to avoid to null)

    mKorbel wrote:
    nice day,
    how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null, Remove the JPanel from the container it was part of and make sure you do not keep any references to it from your own classes. Don't make it any more difficult than it has to be.

  • Difference between PRIMARY KEY and UNIQUE KEY with NOT NULL

    What is the difference between PRIMARY KEY and UNIQUE KEY with NOT NULL constraint?
    Message was edited by:
    Nilesh Hole

    Answer for the master!!!
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8743855576462
    Thanks,
    Karthick

  • Difference between Data staging and Dimension Table ?

    Difference between Data staging  and Dimension Table ?

    Data Staging:
    Data extraction and transformation is done here.
    Meaning that, if we have source data in flat file, we extract it and load into staging tables, we take care of nulls, we change datetime format etc.. and after such cleansing/transformation at then end, load it to Dim/Fact tables
    Pros: Makes process simpler and easy and also we can keep track of data as we have data in staging
    Cons: Staging tables need space hence need memory space
    Dimension Table:
    tables which describes/stores the attribute about specific objects
    Below is star schema which has dimension storing information related to Product, Customer etc..
    -Vaibhav Chaudhari

  • Difference between SAP MI and CRM Mobile Sales

    hi experts,
    we need to understand difference between SAP MI and CRM mobiles sales solutions. what are SAP's  recommendations: where to use MI and where to use Mobile sales.
    can some of you explain the pros and cons of each solution or let me know the place where i get such info.
    thanks in advance.
    RH

    SAP MI apps are aimed at PDAs while CRM Mobile Sales is aimed (and can only work with) at laptops.
    PDA solutions are mostly used by sales agents while the laptop solution is more suitable to account managers. The laptop has much more information available that includes:
    - Marketing planning and execution capabilities
    - Account Planning
    - BW Reporting
    Mobile Sales for PDAs has more basic functionalities like order & activity management and business partner data maintenance (which are also included in the laptop version).
    Message was edited by: João Sousa

  • What's the difference between the ssd and hd?

    I'm in the process of buying a Mac book pro but wanted to know and understand What's the difference between the ssd and hd?

    DDHeadley wrote:
    What's the difference between the ssd and hd?
    HD = hard drive, several metal platters stacked and data read/written magnetically.
    Pro's - less expensive and higher capacity of storage. Can scrub the drive of unwanted data. Unlimited write capability.
    Con'- bit rot can cause data and operating system to not be as reliable, mechanical moving parts means you can't move the machine while it's on.
    SSD = Solid State Disk, basically memory chips that can store data in a permanent fashion without power (like Random Access Memory needs)
    Pro's - faster read/write speeds in most cases. Shock resistant makes them ideal for portable uses.
    Con's - new technology issues, one cannot securely erase the data on them, unless it's ground into a fine powder. Limited write capability means they will wear out eventually like USB thumb drives do. Wear leveling (TRIM) is used to spread the writes evenly across the drive to maximize it's lifespan.
    If you can respect the machine, take care of it and not move it while it's on, or need to scrub the drive of unwanted data, or need higher capacity of storage without paying a fortune for a very large SSD, then a HD makes a lot of sense.
    It really comes down to your privacy, do you want a machine you cannot delete files off of?
    Do you want to carry around a machine that has all your dirty secrets etched in it for anyone with the right software to uncover?
    A computer is a personal machine, why it's called a Personal Computer. We all do things we sometimes are later ashamed of and want to erase all memory of it.
    Can't do that with a SSD, it knows all and you will be forced to destroy the machine to rid it of the unwanted data.

  • What is the difference between VI Template and vi that is reenterant​?

    What is the difference between VI Template and vi that is reenterant?
    From what little info I can find about them, they seem to basically do the same thing....
    What are the difference?
    What are the pros and cons of each?
    Thanks alot for the help.....

    Tarek316 wrote:
    I inherited an app that uses .vit for the purpose of having multipe separate instances.
    Thanks,
    OK, here's what happens when you call a VI Template using Call by Reference or using Invoke and Property Nodes.
    Since the VI you are calling is a template, LabVIEW creates a new instance of that VI by creating a copy of it and giving a new name. Notice in the title bar of the instantiated VI the VI name is the same as the template VI plus a number. This is the same thing you see when you open a template from the "New..." menu. So if you call the template VI 3 times, you'd end up with 5 newly instantiated VIs named, "VI Name 1.vi", "VI Name 2.vi" and "VI Name 3.vi". This is how you end up with multiple instances.
    Reentrancy only works on subVIs when they are used as a normal subVI in a top level application. Using Call by Reference or Invoke and Property Nodes to open and run a reentrant VI results in the VI only being opened once because LabVIEW will not automatically give it a new name. The new name is only generated when calling templates. Since LabVIEW can only a have a single instance of VI name in memory at a time, you'll not end up with multiple instances.
    Not sure if I can help with the know issue on OSX. If it's specific to using the Call by Reference function, you could try calling the templates using Invoke and Property nodes.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Difference between Info structure and Table

    Hi Friends
    I need to know difference between info structure and table (updating a table using a scheduled program),Which one of this is better and why?
    Please help me to get the Pros and Cons of the two available approach.
    Thanks
       Mitesh

    Hi,
         No different, these are just transparent tables like any other. You can select data from them the same as any other transparent table.
    Refer
    https://forums.sdn.sap.com/click.jspa?searchID=4342729&messageID=1424611
    https://forums.sdn.sap.com/click.jspa?searchID=4342729&messageID=3609095
    Regards

  • Difference between Unique key and Primary key(other than normal difference)

    Hello,
    1).Can any one tell me any other difference between Unique key and Primary key other than it having NULLs.
    2). What is the difference the words 'DISTINCT' and 'UNIQUE' in a sql query.
    Thanks in advance.

    Hi
    If you don't believe me than see the documentation in
    OTN.
    Ott Karesz
    http://www.trendo-kft.hu
    SQL> create table scott.tbl_clob
      2  (sss CLOB)
      3  /
    Tabelle wurde angelegt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> select distinct sss from scott.tbl_clob
      2  /
    select distinct sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select unique sss from scott.tbl_clob
      2  /
    select unique sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select distinct to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL> select unique to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL>

  • What is the difference between local printing and remote printing in SAP

    Hello Nation,
    I would like to know what is the difference between local printing and remote printing in SAP and in what scenarios they are used ?
    1.What is local printing in SAP ?
    2.What is Remote Printing in SAP?
    3.what is the difference between local printing and remote printing in SAP ?
    Thank you in Advance.
    Regards,
    -Mohamed Naveen.

    Hi,
    This is SAP Business one system administration forum. Please find correct forum and repost your discussion to get quick response.
    Please close this thread here with helpful answer.
    Thanks & Regards,
    Nagarajan

  • What's the difference between EQ off and flat?

    What is the difference between EQ off and flat? Are all the frequency's at the same place as if it were flat?

    OFF uses iTunes EQ settings, if any.
    FLAT overrides iTunes EQ settings, if any
    Close.
    In Flat, if a song has a preset EQ set in iTunes, it
    will use that preset, otherwise it does not use any
    EQ.
    In Off, the EQ is not used at all.
    Page 28 of the very fine manual for 2n Gen nano:
    Using the Equalizer
    You can use equalizer presets to change the sound on iPod nano to suit a particular music genre or style. For example, to make rock music sound better, set the equalizer to Rock. To use the equalizer to change the sound on iPod nano:
    Choose Settings > EQ and choose an equalizer preset.
    If you assigned an equalizer preset to a song in iTunes and the iPod nano equalizer is set to Off, the song plays using the iTunes setting. See iTunes Help for more information.
    Hmmmm...? There's nano's EQ and iTunes' EQ...

  • What's the difference between shut down and log out?

    Hi,
    I have a MacBook Air and will sell it.
    I like to take out my name but don't know how.
    What will happen if I Log Out (my name comes after that)?
    What's the difference between Shut down and Log out?
    Help please,
    Thanks

    Welcome to the Apple Support Communities
    The shut down turns off the Mac and a log out closes your user and take your computer to the log in screen. To sell the Mac, you have to reinstall Mac OS X erasing the disk. Open  > About this Mac and copy Version

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • I want to know the difference between Days column and Day1 Column

    Hi All,
    I used this query:
    SELECT to_char(return_date_time,'dd/mon/yyyy hh24:mi:ss') Test,
    DECODE ('I', 'I', DECODE (1, NULL, NULL, 0, NULL, SYSDATE + 1)) Days,
    DECODE ('I', 'I', SYSDATE + 1) Day1
    FROM fm_curr_locn
    WHERE patient_id = 'DU00002765'
    output: 
    Test
    Days
    Day1
    26/oct/2013 00:00:00
    26-OCT-13
    10/26/2013 3:06:59 PM
    I want to know the difference between Days column and Day1 column and why the days column didnt show the time
    Please anyone help.....
    Regards
    Shagar M

    Pleiadian wrote:
    It is the decode statement that is doing this.
    The format of decode is:
    decode(expression, search1, result1, search2, result2, searchn, resultn, default)
    All result fields must be of the same datatype and will be of the datatype of the first result (result1 in this example)
    In your example (the decode for the field Days) the first result is a NULL. I suspect (gurus? anyone?) that Oracle will use the varchar2 overload of the decode statement, and the date field will be converted to varchar2 using your NLS_DATE_FORMAT settings.
    In the second decode statment (Day1) the first result is of datatype date, so the result of the decode statement will be a date field (and will be parsed as such by your sql development tool)
    I agree, as NULL is the first result returned the datatype is undetermined, so Oracle is picking VARCHAR2 over others, and causing an implicit datatype conversion on the resultant date value, whereas the other which is returned as a date will use the local settings of the client tool being used.
    I can replicate the 'issue' in Toad, and it's rectified if we cast the first returned value of the decode statement...
    SELECT DECODE ('I', 'I', DECODE (1, NULL, CAST(NULL AS DATE), 0, NULL, SYSDATE + 1)) Days,
           DECODE ('I', 'I', SYSDATE + 1) Day1
    FROM dual

  • What's differences between camera roll and photostream?

    what's differences between camera roll and photostream files?

    Camera Roll is all photos & videos taken directly with the device, including screenshots, and also any images saved from a text message, email or website.
    Photostream is a service that, after you've taken such a photo, after you close out the Camera app (or switch to a different app or your home screen), uploads a copy of that photo via wi-fi to your iCloud Photostream account. 
    Camera Roll photos are saved until you delete them.
    Photostream photos will remain in Photostream for 30 days minimum.  After that, they will be automatically purged from the system.  If there are photos in your Photostream that you would like to save permanently, copy them to your iPhone's Camera Roll, or download them to your computer using the iCloud Control Panel.

Maybe you are looking for

  • Why is the "microphone" missing on my iPhone in Mail?

    Just today I noticed that the little microphone is missing from the Mail keyboard when sending Mail. Why?

  • Mail only works with Font Book open

    I copied a lot of fonts to my laptop and all the fonts would show up on my desktop publisher. I did not want all the fonts enabled so I disabled the ones I didn't need. Later I noticed that I needed to enable essential fonts for my system, so I did t

  • Re: Satellite A210-10A, crashes when changing boot order

    Hello, I have a serious problem with my Toshiba laptop, Windows Vista 32bit, 1.8Ghz, 2Gb RAM, AMD Turion 64 x2 There is one hard disk partitioned as two 75Gb drives (C and E). The problem is that, whenever I enter the Boot menu (to boot from CD), or

  • Pages 5: How can I put a picture in the header of a Page?

    In the previous version (4.3) this was no problem. This seems not to possible any more?

  • Kernel_task at 100% CPU

    Hi guys, I have a Macbook Pro Retina Display, running 10.8.2 Every two days or so, I notice that my computer gets really hot and either freezes up, or acts slow.  Activity monitor tells me that the kernel_task is at 100% usage (or more) at this point