Do v need to Close the Connection

Hi plz tel me
1. Do v need to Close the Database Connection ?
2. which is better to use Statement or ResultSet Interface ?
Thanx in Advance

Hi plz tel me
1. Do v need to Close the Database Connection ?
2. which is better to use Statement or ResultSet
Interface ?
Thanx in AdvanceHi sumit.manhas,
For your info, refer these links....
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.htmlpublic interface Statement
The object used for executing a static SQL statement and returning the results it produces.
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.htmlpublic interface ResultSet
A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.
Regards,
JavaDriver

Similar Messages

  • We need to open the connection each time you read a message from the queue?

    Hi
    I have a doubt regarding my queue read data that contains those I create a session and connection.
    Whenever I do this or you can create a connection and get all data from the queue and then close the connection and session
    eg. I have 1000 files in the queue and I read all files but without creating a session and a connection every time you get a single figure, this can be done?
    I read the 1000 files without having close the session or the connection
    thanks for the help.

    I answered myself.
    No need to open a connection and a session each to be read from a data queue to extract the entire contents of the queue with only one session and open a single connection.

  • Firefox won't open a message tells me it is all ready running I need to close the window to open firefox. Firefox is not open so why do I get this message

    When I try to open firefox a box opens up and tells me firefox is already running in another window and I need to close the window if I want to open firefox in a new window. Firefox is already closed, nothing is left open when I close out firefox. I would only have this problem once in a while but now it is happening more often why?

    Open Task Manager and click on the Processes tab. Scroll down to "Firefox.exe" , click on that line and click on "End Process" button.

  • APS Daemon.exe has encountered a problem and needs to close the computer

    On my Lenovo laptop at home, I am getting a message:  " APS Daemon.exe has encountered a problem and needs to close the computer".
    This message appears after my computer (lap-top at home)  gets automatically shut down and is restarted by me.
    I believe that, this file pertains to an "Apple application Support Application" and impacts the PC only when I am transferring CDs to iTunes (for my iPad 2)
    Any help in resoloving this problem is highly appreciated.
    Harish

    I was having this problem few days ago,and I have fixed.Try this steps-If you have AVG antivirus so go on firefox>Tools>Add On and Disable AVG safe search and AVG tool bars too.Then restart computer.

  • You may need to configure the connection settings in the deployment descrip

    Hi All
    I am new to BPEL and going through Order Booking Tutorial (using 10.1.3.4 version of opmn ) .
    I have a problem in 'Designing the Database Adapter to Insert Data' Chapter.
    I have installed Oracle 10g Express Edition and BPEL Process Manager on my local system.
    In the Example it has been asked to create a daabase connection with Third Party JDBC Driver. Instead I have created a database connection with Oracle(JDBC) Driver.So i didnt have to register any third party driver.
    I cud access the Order/OrderItems table as well .
    I Deployed the same on the server.But while running the process I get following error--
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    nested exception is:
         ORABPEL-11622
    Could not create/access the TopLink Session.
    This session is used to connect to the datastore. [Caused by: Listener refused the connection with the following error:
    ORA-12519, TNS:no appropriate service handler found
    The Connection descriptor used by the client was:
    localhost:1521:XE
    See root exception for the specific exception. You may need to configure the connection settings in the deployment descriptor (i.e. $J2EE_HOME/application-deployments/default/DbAdapter/oc4j-ra.xml) and restart the server. Caused by Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.4.0) (Build 080602)): oracle.toplink.exceptions.DatabaseException
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    I have checked several post on this error but every post talks about third party database.I have used Oracle Database only so why/What shud I change anything in oc4j-ra.xml?? This is my doubt .
    Pls help me on this .Also Let me knowe in my case is there any need to create the datasource.?I am low at concept of database.
    Pls help
    Regards
    Naveen

    Hi
    I am trying to insert orader and order Items as given in the Order booking tutorial..
    Here are the files description
    .wsdl file looks like
    <service name="DBInsert">
    <port name="DBInsert_pt" binding="tns:DBInsert_binding">
    <jca:address location="eis/DB/MyConnection"
    UIConnectionName="MyConnection"
    ManagedConnectionFactory="oracle.tip.adapter.db.DBManagedConnectionFactory"
    mcf.DriverClassName="oracle.jdbc.OracleDriver"
    mcf.PlatformClassName="oracle.toplink.platform.database.oracle.OraclePlatform"
    mcf.ConnectionString="jdbc:oracle:thin:@localhost:1521:XE"
    mcf.UserName="system"
    mcf.Password="6672B62098892995C8B651EFDF798A59"
    />
    </port>
    </service>
    data source file looks like
    <connection-pool name="MyConnection">
    <!-- (DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=tcp)(HOST=nakhanna)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=XE))) below is in the form: [hostname]:[port]:[oracle sid]" -->
    <connection-factory factory-class="oracle.jdbc.OracleDriver" user="orabpel" password="->pwForOrabpel" url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=tcp)(HOST=nakhanna)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=XE)))"/>
    </connection-pool>
    <managed-data-source name="MyConnection" connection-pool-name="MyConnection" jndi-name="jdbc/MyConnectionDS"/>
    </data-sources>
    oc4j-ra.xml looks like
    <connector-factory location="eis/DB/MyConnection" connector-name="Database Adapter">
              <config-property name="xADataSourceName" value="jdbc/MyConnectionDS"/>
              <config-property name="dataSourceName" value=""/>
              <config-property name="platformClassName" value="oracle.toplink.platform.database.Oracle9Platform"/>
              <config-property name="usesNativeSequencing" value="true"/>
              <config-property name="sequencePreallocationSize" value="50"/>
              <config-property name="defaultNChar" value="false"/>
              <config-property name="usesBatchWriting" value="true"/>
              <connection-pooling use="none">
              </connection-pooling>
              <security-config use="none">
              </security-config>
         </connector-factory>
    ##################################################################3
    Still I get the same error .
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>null</code>
    </part><part name="summary"><summary>file:/C:/product/10.1.3.1/OracleAS_1/bpel/domains/default/tmp/.bpel_FulfillOrder_4.0_e77c64251e45eb4711a3a093f92e6a86.tmp/DBInsert.wsdl [ DBInsert_ptt::merge(OrdersCollection) ] - WSIF JCA Execute of operation 'merge' failed due to: java.util.MissingResourceException
    java.util.MissingResourceException
    ; nested exception is:
         ORABPEL-00001
    java.util.MissingResourceException
    java.util.MissingResourceException
    java.util.MissingResourceException
    </summary>
    </part><part name="detail"><detail>null</detail>
    </part></bindingFault>
    Pls let me know if something looks wrong in the above files
    Thanks
    naveen

  • HT1199 Hai, i tried to open itunes on my windows 8 laptop but it comes out with 'iTunes has stop working' notification and need to close the program everytime i try to load it. Please help! thanks.

    Hai, i tried to open itunes on my windows 8 laptop but it comes out with 'iTunes has stop working' notification and need to close the program everytime i try to load it. Please help! thanks.

    Hi ajay-9,
    Thanks for visiting Apple Support Communities.
    The steps in this article can help if iTunes is quitting unexpectedly on your PC:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/ts1717
    Cheers,
    Jeremy

  • Need to close RFC connection

    Hi all,
    Currently we developed a application in NWDS, the same is operational from portal.
    As per the requirment we have to run the RFC many times to extract the data from R/3. After running the RFC many times
    we are getting the following Error "Error connecting using JCO.client: null"
    But if we redeploy the application the problem is solved but after a while the same issue is persisting.
    Please suggest how the problem can be solved ??
    Thanks,
    vijay.

    Hi venkat,
    Thanks for the example suggested by you.
    The following is the RFC iam executing many times.
    Z_Hr_Aprsl_Init_Input input= new Z_Hr_Aprsl_Init_Input();
    input.setI_Usrid("UserId");
    wdContext.nodeZ_Hr_Aprsl_Init_Input_new().bind(input);
    wdContext.nodeZ_Hr_Aprsl_Init_Input().currentZ_Hr_Aprsl_Init_InputElement().modelObject().execute();
    the code iam using to close the connection is
    JCO.Client client = JCO.getClient(" "); // Please specify the parameter to be used to refer the above RFC
    client.disconnect();
    Please suggest the required the parameter to close the RFC connection
    Thanks
    vijay

  • Can I close the connection after sending immediately on the server?

    I have a C/S program. On the server side, the process as following:
    1. accept (blocking)
    2. //a connection is established
    using a new socket to receive request data from client
    3. business processing ... (maybe several seconds)
    4. send response data to client
    5. close socket immediately
    6. listening continuely again
    The server side is running on linux and writed by Java, and client is running on windows and writed by C++ Builder.
    My problem is:
    1. if the server is running on windows, everything is OK.
    2. if the server is running on linux (that is exprcted), the client can not receive the response data from server, the client program said the connection is unavailable when he read from socket blockingly.
    3. if I add some delay, e.g. 500ms, between sending response and close the connection, the client can receive response normally.
    why above?
    thanks for help.
    Jack

    Sorry, long time to go away.
    package test.server;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class EchoServer {
         private int port; // listened port
         private ServerSocket ssock; // the server's ip
         public EchoServer(String host, int port) {
              this.port = port;
              // Create a ServerSocket
              try {
                   ssock = new ServerSocket(port);
                   SocketAddress addr = new InetSocketAddress(host, port);
                   ssock.bind(addr);
              } catch (Exception ex) {
                   ex.printStackTrace();
              new HandleThread().start();
         public class HandleThread extends Thread {
              public int ntohl(byte[] bytes, int offset) {
                   int length1 = ((((int) bytes[offset + 0]) << 24) & 0xff000000);
                   int length2 = ((((int) bytes[offset + 1]) << 16) & 0x00ff0000);
                   int length3 = ((((int) bytes[offset + 2]) << 8) & 0x0000ff00);
                   int length4 = ((((int) bytes[offset + 3]) << 0) & 0x000000ff);
                   return length1 + length2 + length3 + length4;
              public void run() {
                   InputStream in = null;
                   OutputStream out = null;
                   try {
                        while (true) {
                             System.out.println("Start Listening...  [" + port + "]");
                             Socket clisock = ssock.accept();
                             //clisock.setSoLinger(true, 1);
                             System.out.println( "SOLinger:" + clisock.getSoLinger());
                             try {
                                  System.out.println("Accepted Client Socket...  [" + clisock + "]");
                                  in = clisock.getInputStream();
                                  out = clisock.getOutputStream();
                                  // receive four bytes length
                                  byte[] lenbuff = new byte[4];
                                  in.read(lenbuff, 0, 4);
                                  int len = ntohl(lenbuff, 0);
                                  byte[] buff = new byte[len];
                                  in.read(buff, 0, len);
                                  System.out.println("Received length&#65306;" + len + "  " + new String(buff));
                                  Thread.sleep(1000);
                                  out.write(lenbuff);
                                  out.write(buff);
                                  out.flush();
                                  //Thread.sleep(500);
                                  System.out.println("Send finished&#12290;");
                             } catch (Exception ex) {
                                  ex.printStackTrace();
                             } finally {
                                  if (in != null) {
                                       try {
                                            in.close();
                                       } catch (Exception ex) {
                                  if (out != null) {
                                       try {
                                            out.close();
                                       } catch (Exception ex) {
                                  if (clisock != null) {
                                       try {
                                            long time00 = System.currentTimeMillis();
                                            clisock.close();
                                            System.out.println( "close socket&#65306;[" + (System.currentTimeMillis() - time00) + "]");
                                       } catch (Exception ex) {
                   } catch (Exception ex) {
                        ex.printStackTrace();
         public static void main(String[] args) throws Exception {
              if( args.length == 2 ) {
                   new EchoServer(args[0], Integer.parseInt(args[1]));
              } else if( args.length == 2 ) {
                   new EchoServer("127.0.0.1", Integer.parseInt(args[0]));
              } else {
                   new EchoServer("127.0.0.1", 16000);
    }In my application, the package is following:
    length(4bytes) + data
    I have a simple WinSocket Client, send data to this server and receive the response,the sending is OK, Server can receive all messages.But when client is ready to receive data, the winsock call return WSAECONNRESET(10054).
    If I uncomment "Thread.sleep(500);", it means wait some time before close socket, the client can receive all response data.
    why?

  • My Firefox.exe process remain open after I close the browser.If I open it it's says to open a new window.I need to close the process manualy(Ctrl+Alt+del).What can I do?Thanks .

    Need to close the process.

    It does take Firefox a while to shut down; it has to update some databases. But it should take less than a minute.
    In the support article, this problem is called a "hang at exit" because Firefox hangs when shutting down. Maybe something here will help: https://support.mozilla.com/en-US/kb/Firefox+hangs#Hang_at_exit
    Also, sometimes open Firefox windows disappear from the Task Bar. You can use Alt+Tab to switch to them if they remain open.

  • What happends if I dont close the connection

    Hi,
    I would like to know what happends if I dont close the connection after processing. we wont get any compile time & run time error if you dont close the connection. But why we used to close the connetion. Any specific reason for this. Please let me know.
    Regards,
    Satish

    What happens if you don't close a connection? It depends on how many connections you open and how long your program keeps running.
    Let's start with the case of a standalone program that runs for a little while then exits.
    While the program is running, the operating system maintains a network connection to the database server for each open database connection; there are system limits on the number of open network connections, although this is usually a very high number. Also, every open connection to a database uses resources of the database; many databases have limits on the number of connections they can have open at once. Some database products or configurations (Oracle in "dedicated" mode) will also start a seperate process on the server for each open connection; too many open connections and these processes start swapping out to disk, too many more and the server runs out of memory.
    When the program exits, the operating system will close any open network connections; the database server will also recognize that the network connections are closed. If the database supports transactions and the connection was in a transactional mode and there were uncommitted transactions, then the uncommitted transactions will be rolled back. Ultimately, all the database resources get released (assuming there are no bugs in the database program).
    Thus, a program that runs for a few minutes, commits all its transactions and exits without closing connections doesn't do major harm; the operating systems of both the client and the database server clean up the network connection and the database itself cleans up the database connection. It's all designed this way because programs sometimes crash; you can't have a system/database that breaks when that occurs... However, this cleanup is not always absolutely immediate on program exit; it usually takes a short time, seconds to minutes, for everything to clean up. Therefore, if the same programs is run over and over real fast, it becomes possible to exhaust a resource, such as memory or network connections. For a quick little test program that's run once and that's it, no problem...
    Now for a long running prgram, such as a web application that will run for days or months...
    As I've alluded to above, each database connection uses system resources, both on the client machine and on the database server. When a connection is maintained open, those resources are tied up; there's always a limit on the total number of connections that can be supported, although with the right software, hardware and database configurations that limit can be a huge number, tens of thousands. For other systems, it might be a low number, hundreds or less. Whatever it is, the program could potentially reach that limit and cause something to fail. If it doesn't reach that limit (or cause another program to push past the limit) then there's no problem (other than a potential performance impact).
    Now within a Java program, the JDBC standard requires that when an open database connection object is garbage collected, the connection is first closed. Assuming your driver conforms to the standard in this regard, and assuming no resource limit gets exceeded, then a long running program could open and abandon connections and let the garbage collector close and clean up. However, garbage collection is unpredictable, and connections are often sufficiently long lived that they get moved out of the "Eden" memory space and into the space of long-lived objects. These objects are only garbage collected when a "full" garbage collection takes place; a "partial" collection only examines the "Eden" space. Thus, depending on the applications load and memory usage and connection usage pattern and garbage collection configuration, an abandonded connection might not be garbage collected for hours or even days, greately increasing the chances that you run out of resources.
    In other words, not closing your connections in a long running program is a really really bad idea.

  • Using LabVIEW 6i w Win NT or 95/98 et al: how do you keep a TCP/IP open connection 'open'. The application closes the connection even though the refnum is still active (valid.)

    Actually, I open the TCP/IP connection and pass the connection ID through. Each command to/from (cycle) the UUT successfully executes. The refnum for the connection ID is then passed via a shift register in the while loop. i am using the type cast (4X) function to determine the validity of the connection and case statements. If the refnum is non-zero it assumes the connection is still open; if the result is zero, then the connection is closed and a new session opened in that case. What is happening is that the connection has closed and the refnum is still nonzero after the type cast function; su
    bsequent commands to the UUT then produce Error 1 for the TCP/IP function (there was no open connection, so there could be no write occurrence.) Obviously, this probably shouldn't be happening. If someone can give me some idea of what I am not doing, or am doing wrong, I sure would appreciate it. In the event that I open and close a connection for each command to(from)(cycle) the UUT everything works. It is extremely slow. The connection should remain open according to all the pointers in the Help and TCP/IP function descriptions. Some of this application is proprietary, so not sure how much of an example I could use to illustrate from a VI, but if this doesn't get any where, I will see what i can do to better illustrate the problem...Thanks. T.Raper

    I believe this is a related question. I am developing a LV application the uses TCP/IP to control up to 8 devices-under-test (DUT) at one time. They start and finish testing at arbitrary times relative to each other, and the IP addresses are not known until the DUT arrives. I have some question on what is the best way to manage the TCP/IP handles.
    Presently, I have 8 Global IP addresses (one per testing site) that are updated as DUTs arrive and depart, and then whenever I need to communicate with a DUT I use TCP-Open, Write/Read, and TCP-Close. I do this Open/Write/Close each time there is a message to be sent to a DUT. This is basically working, but I notice that the OS (Windows XP or 2000) is running through local TCP/IP ports at a ferocious rate due to the TIME_WAIT behavior of Closed TCP/IP ports (It takes many minutes for a local port to become available again after being closed). If I am not careful, I can quickly exhaust the pool of OS ports by using tight polling loops or other very quick DUT accesses. I have tried not to do that in order to avoid running out of handles, but it is still very wasteful of ports.
    While it is working, I feel so dirty burning through these handles like this since they appear to be a precious resource. I really cannot easily merge multiple Read/Writes into a single Open/Close since there are dozens of otherwise unrelated tests that communicate with the DUT as a part of their functionality. The tests are even in different subVI's that are accessed via a vi-server, and only one is loaded at a time.  
    I thought that a cute idea would be to cache the handles in Globals, and wrap the Open to use the cache if valid, but reading this thread is making me think it is a lot of effort -- I believe I would need to keep a VI running as a "IP Connection Server" at all times and use some form of messaging to get it to Open/Close TCP connections as needed. Since the DUTs arrive at aribitrary times, and with random IP addresses, I cannot establish all the TCP handles ahead of time -- they would need to be created dynamically. It is much more difficult than simply keeping the Connection IDs in global variables -- the VI that Opened them must not be allowed to terminate.
    So... I am curious...... is it really that bad to Open/Close as frequently as I am doing it? Does it make me a bad person? I understand it is inefficient use of time, but the simplicity it brings to the structure seems huge, and the DUT is very slow anyway. And if it is bad, are they any more recent thoughts on alternatives? Do VISA handles behave the same way as TCP handles (ie. auto-close themselves upon exit of the VI that Opened them) ?
    Message Edited by Mike Seibel on 11-28-2005 07:55 PM
    Message Edited by Mike Seibel on 11-28-2005 08:00 PM
    Message Edited by Mike Seibel on 11-28-2005 08:01 PM

  • Blackberry 8800 closes the connection with the desktop manager

    i have blackberry 8800... when i try to connect with the desktop manager 5.0 it connects flawlessly but after some seconds a message appears that your device has lost the connection with the desktop manager but even then the usb sign stil being showed infront of the battery indicatior... after some seconds of losing the connection, it connects again and disconnects again and this is goes on ....
    i need help please
    regards

    please help me . is theres any solution to it. done battery replacment reset. but nothing happens

  • Why do I get an error message that tells me I need to close the current session of Firefox. It is open somewhere and I must restart my computer to get past this. Why?

    I cannot open Firefox on my system as a message opens that tells me I must close the session that is currently running. However, I have not opened it and it doesn't show anywhere on my computer that it is open. The error message tells me that I must restart my computer which I have to do to get past this point. Then it works fine after that. I have been using Firefox for about 5 months and it has happened about 6 times now. A bit frustrating I must say. Thank you for your assistance on this matter.

    Open Task Manager and click on the Processes tab. Scroll down to "Firefox.exe" , click on that line and click on "End Process" button.

  • Need to close the PR

    There is a scenario of Third party, in which, Sales Order are created of 10 qty, PR created automatically with 30 qty, GR  and IR are done with 10 qty. this is old PR and obviously showing as open. So can anybody suggest me:
    1. How PR fetched the qty of 30 whether Sales order was of 10 qty.
    2. How can I close the PR, becasuse closed ind. in the PR is showing as graied out.

    Go to sales order and change the PR qty in sales order, not in ME52N.
    Regards,
    Dakshesh

  • Everytime I set up my macbook as a wifi hotspot it closes the connection on my macbook.  Why does that happen?

    Everytime I set up my computer as a wifi hotspot it closes my computer's internet connection.  Why is that happening?  And What can I do?

    With a Thunderbolt to Ethernet adapter in use, your MacBook Pro's Network Preferences should be similar to this:
    "Status" should be "Connected", a valid IP address should appear, and you should be able to load web pages. Make that work first.
    Then make your MacBook Pro's Sharing preferences resemble this:
    Essentially: "Share your connection" and "To computers using" should be as shown above.
    The MBP's Wi-Fi icon will be as shown below:
    To other client devices, the network they join should be the name you designated. It will appear in the same manner as any other wireless network.
    What are you seeing that's different than the above?

Maybe you are looking for

  • How can I get an album from my iPod Classic 80GB onto my refurbished MacBook Air?

    Hi there I have a new to me refurbished MacBook Air and an old iPod Classic 80GB.  I've somehow managed to get my music off my iPod onto my laptop apart from one album which doesn't seem to have copied across.  Please could anyone tell me how to do t

  • I cant get into my iTunes account anymore :(

    To anyone who can help,      I set up an iTunes on my computer so I could buy songs from a bigger screen. Which exactly what I intended to do. I enter in my hard earned 50 dollar gift card ready to start jamming to much needed new songs, when it says

  • Problen in free goods determination

    hi buddies when i was creating the free goods determination ,i am getting this error"alternative unit of measure EA not defined". i given mat,qty,from,free goods,cl, and all and its asking unit of measure when i try to give EA overther, its saying th

  • Sales order not getting created in background.

    I am using user exit to write my code to create sales order of basic type ORDERS05 with function module idoc_input_orders, and process code ORDE with my own message type. If I run the program in foreground message KUWEV-KUNNR is not an input field co

  • Expanding menu bar help

    i have search for about 2-3hrs and cant figure out how to create a vertical expanding navigation bar like the one on www.louisvuitton.com on their main page there is a menu box on the right and when you put your mouse over it it expands allowing you