Connection closes autometically

Hi,
I am making multiplayer game,
my problem is:
a player after connecting to mediaserver, if he does not play
for some time , he losses connection with the mediaserver.
why the player is disconnected, i am not getting any
notification when player is disconnected, how to trace this.
and also i don't want the player to be disconnected if he
does not play for sometime.
please help me in solving this.
regards
avanthika

Horea Raducan wrote:
>
Is it true that if you close a connection, all the results sets
associated with that connection will be also closed and you don't have
to close them ?Yes. This is mandated by the JDBC spec. For safety and performance,
however, it is best if you close the result set asap, then close the
statement asap, and most crucially, never forget to close the connection.
The reason why you want to close resultsets and statements asap,
is because they may involve DBMS resources like cursors etc, and these
can be freed for re-use when you close the object, but may remain
unuseable for a while if you rely on the connection close() to
clean up after you.
Joe

Similar Messages

  • Difference between connection = null and connection.close()

    is it correct
    connection = null means connection object is eligible for garbage collection and does not return to connection pool
    and f or
    connection.close() means the connection object return to the
    connection pool
    is there any other difference between this ....?????

    "connection = null;" is just like any other similar Java statement, it removes that reference to the object. If that was the last reference to the object, then it becomes eligible for finalization and garbage collection, with no guarantee that either will actually occur. However, normal connection pool implementation will have a seperate reference to the connection and if the connection has not been returned, will most likely consider the connection to be "leaked" - allocated but never returned, and unusable.
    connection.close(); is a normal JDBC connection method; it (usually) closes the associated objects and releases the connection; it's not uncommon to explicitly close statements and resultsets instead of depending on connection.close(). A connection pooling implementation that works by extending the Connection class MIGHT change the meaning of close() and instead of actually closing, return it to the pool instead. Personally, I would consider such an implementation to be evil and a blight on good programming practices; changing the action of such standard methods is bound to cause trouble, IMHO. More normally, if you were using connection pooling, you would NOT close the connection, but rather call some special method to return the connection to the pool.

  • Web app Connection.close()...how to prevent

    Hello
    I am somewhat new to this, but I am developing an web application that will be a help desk of sorts for clients to log on and create trouble tickets, plus many other features. I have completed the project and it works fine when I first start tomcat but an unexpected state keeps occurring and I can't seem to figure it out.
    After a while (I say a while cause I'm not sure exactly how long, but I'd say +5 hours) my application no longer will work and in the tomcat log I get the following message.
    Could not execute a query statement!Connection.close() has already been called. Invalid operation in this state.
    java.sql.SQLException: Connection:close() has already been called.
    at com.mysql.jdbc.Connection.getMutex(Connection.java:1906)
    at com.mysql.jdbc.Statement.executeQuery(Statement.java:1115)
    at brokers.RelationalBroker.query(RelationalBroker.java:171)
    the RelationalBroker.java is
    package brokers;
    * Created on May 12, 2004
    * Class: RelationalBroker
    * Package: brokers
    * On-Track, Ticket Tracking System
    * @author
    * @version
    * This Class is used as the super class for all of the child brokers
    * for the database. The main purpose if this class is to allow all the
    * child classes to share the open connection to the database and execute
    * queries and updates on the database. This class is part of the brokers
    * package.
    //imports
    import java.sql.*;
    public class RelationalBroker {
        //Instance Attributes
         * The attribute con represented by a Connection object is used to hold
         * the active connection to the database. This connection is shared with
         * all of the child brokers.
        private Connection con = null;
         * The attribute statement represented by a Statement object is used to
         * execute the query and update statements on the database by the child
         * brokers.
        private Statement statement = null;
         * The attribute results represented by a ResultSet is used to hold
         * the results of a query executed on the database.
        private ResultSet results = null;
        //Constructors
         * Default constructor used to create a RelationalBroker object.
        public RelationalBroker(){
        //     Getters
         * The Getter getCon is used to get the Connection object.
         * @return Connection con.
        public Connection getCon() {
            return con;
         * The Getter getResults is used to get the ResultSet results.
         * @return ResultSet results.
        public ResultSet getResults() {
            return results;
         * The Getter getStatement is used to get the Statement object.
         * @return Statement statement.
        public Statement getStatement() {
            return statement;
        //Methods
         * The method connect is used to connect to the database given a username
         * password, location of driver, and URL of the database. This method also
         * creates the Statement object to be used for queries ans updates on the database.
         * @param driver A String containing the location of the database driver.
         * @param URL A String containing the location of the database on a netowrk.
         * @param user A String containing the username of the database account.
         * @param pass A String containing the password of the database account.
        public void connect(String driver, String URL, String user, String pass){
            try{
                Class.forName(driver);
                con = DriverManager.getConnection(URL, user, pass);
                statement = con.createStatement();
            catch (ClassNotFoundException cExp){
                System.out.println("Cannot find class for driver");
            catch (SQLException sqle){
                System.out.println("Error opening table or creating statement!: " + sqle.getMessage());
                sqle.printStackTrace();
                System.exit(0);
         * The method closeConnection is used to close the active connection
         * to the database.
         * @return A boolean containing the status of the connection, True if closed
         * false if open.
        public boolean closeConnection(){
            boolean isClosed = false;
            try{
                con.close();
                isClosed = con.isClosed();
            catch(SQLException sqle){
                System.out.println("Error closing connection!" + sqle.getMessage());
            //finally{
            return isClosed;
         * The method rollBack is used to execute a rollback statement on
         * the database, to undo any changes since the last commit.
         * @return void
        public void rollBack(){
            try{
                con.rollback();
            catch(SQLException sqle){
                System.out.println("Could not execute a  Rollback statement!" + sqle.getMessage());
                sqle.printStackTrace();
         * The method commit is used to execute a commit statement on the
         * database, to make any changes final.
         * @return void
        public void commit(){
            try{
                statement.executeUpdate("commit");
            catch (SQLException sqle){
                System.out.println("Could not execute a commit statement!" + sqle.getMessage());
                sqle.printStackTrace();
         * The method query is used to exceute a query statement on the
         * database to get back some results.
         * @param query A String containing the query to be executed on the database
         * @return a ResultSet containing the results.
        public ResultSet query(String query){
            results = null;
            try{
                //System.out.println("query: "+query);
                results = statement.executeQuery(query);
            catch(SQLException sqle){
                System.out.println("Could not execute a query statement!" + sqle.getMessage());
                sqle.printStackTrace();
            //finally{
            return results;
         * The method update is used to persist or remove information
         * from the database.
         * @param update String containing the update string to be exceuted;
        public void update(String update){
            try{
                statement.executeUpdate(update);
            catch(SQLException sqle){
                System.out.println("Could not execute an update statement!" + sqle.getMessage());
                sqle.printStackTrace();
    }//end classmy web.xml file to initialize with the database is as follows
    <servlet>
              <servlet-name>Connection</servlet-name>
              <servlet-class>servlets.ConnectionServlet</servlet-class>
              <init-param>
                   <param-name>url</param-name>
                   <param-value>jdbc:mysql://localhost/TICKETTRACK</param-value>
              </init-param>
              <init-param>
                   <param-name>driver</param-name>
                   <param-value>com.mysql.jdbc.Driver</param-value>
              </init-param>
              <init-param>
                   <param-name>user</param-name>
                   <param-value>---</param-value>
              </init-param>
              <init-param>
                   <param-name>password</param-name>
                   <param-value>---</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
         </servlet>
    the ConnectionServlet.java is
    package servlets;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import problemDomain.*;
    import brokers.*;
    * Title:
    * Description:      This servlet is used to create a connection with .
    * @author
    * @version 1.0
    public class ConnectionServlet  extends HttpServlet{
        private UserBroker uBroker;
        private TicketBroker tBroker;
        private CompanyBroker cBroker;
        public void init() throws ServletException{
            ServletConfig config = getServletConfig();
            String user = config.getInitParameter("user");
            String pass  = config.getInitParameter("password");
            String url  = config.getInitParameter("url");
            String driver = config.getInitParameter("driver");
            uBroker = UserBroker.getUserBroker();
            tBroker = TicketBroker.getTicketBroker();
            cBroker = CompanyBroker.getCompanyBroker();
            uBroker.connect(driver,url,user,pass);
            tBroker.connect(driver,url,user,pass);
            cBroker.connect(driver,url,user,pass);
    /*  This method is used to close the connection.
    *  @param none
    *  @return none.
        public void destroy() {
            try{
            }catch(Exception ec){
                System.err.println(ec);
    }I hope this is enough information for someone to help out. I'm out of ideas and my searches on the web didn't turn up much.
    I was thinking it was something to do with ConnectionPooling but I have never done that, or maybe its something to do with how I set up Connections or maybe its my Tomcat config or something to do with Mysql. I'm not even calling a Connection.close(), maybe that is my problem.
    Any help would be greatly appreciated, I'm not just looking for an answer I really would like to know why this occurs and how it can be prevented.
    Thanks,

    I really appreciate your reply and I can understand what you mean in theory(I think) but to actually implement it I'm having a little trouble.
    So for this database pool, in my ConnectionServlet which gets initialized on startup, should I create a Collection of connections for each instance(make them local), and than create another method to retrieve one of these connection when needed and when finished release it back to the collection(close)? Or is there some built in mechanism that can easily do this?
    I'm also reading up on that keep-alive you mentioned...it applies to the HTTP Connector element right? Is there a way to tell if this is an issue? I'm using Tomcat 5 and mySQL 3. I was talking with another guy here about using a connector to apache so it will work with the static pages and Tomcat do the servlet stuff, but I'm still trying to grasp all that.
    I don't know if this matters but many instances/windows of the web app can be opened at one time with seemingly no problems.
    Hope this made sense, like I said I'm pretty new to this so all I'm used to is simple configurations of web apps but hopefully I can advance further.
    Thanks again,

  • Socket POST connection close

    Hello all,
    I was wondering if there was a way to close a connection once the server writes back to the connection? I have this post:
    var conn = new Socket;
    //conn.timeout = 300;
    //conn.timeout = 10;
    conn.timeout = 2;
    var tempzzz = $.hiresTimer;
    conn.open(vHost);
    conn.write("POST " +vSubDir+"/update.asp HTTP/1.1\r\n");
    conn.write("Host: " + vHost + "\r\n");
    conn.write("Content-Length: " + data_string.length + "\r\n");
    conn.write("Content-Type: application/x-www-form-urlencoded\r\n");
    conn.write("\r\n");
    conn.write(data_string);
    var reply = "";
    reply = conn.read(999999);
    conn.close();
    var myTime = $.hiresTimer/1000000;
    alert("found reply "+myTime)
    When I run this code with the timeout set to 2 my alert states found the reply in 1.75 sec.
    When I run this code with the timeout set to 10 my alert states found the reply in 9.87 sec.
    When I run this code with the timeout set to 300 my alert states found the reply in 126.23 sec.
    Any idea how to close the connection and therefore make indesign active again the moment a server replies? I cannot use a get because I am sending a lot of data to the server which would exceed the URL size limit. Any information would be helpful, thanks!

    Hi,
    when you are talking about the weblogic level, connection pooling is implemented through configiration level,
    Please note we have 3 variables in configiration level :
    1. InitialCapacity
    2. MaxCapacity
    3. CapacityIncrement
    initialCapacity means the number of physical connections which will open during the starting of the Server.
    which can be initially 0, MaxCapacity means the number of maximum connection which can be opened. i mean maximum physical connections.CapacityIncrement means if it finds like the number of opened coonection is used then it will again open that much Capacity increment of connection. Please not this will not increase the MaxCapacity.
    when you are closing the cnnection using connection close methord, you are returning the connection to connection pool , which will increase the number of connection available in the connection pool.
    Regards,
    Anu Unnithan

  • HTTP/1.1 200 OK Server: Microsoft-IIS/7.5 Connection: close in Sharepoint 2010

    Hi to all,
               This is siddiqali working on sahrepoint 2010.I open my Web application then i got error as
    HTTP/1.1 200 OK
    Server: Microsoft-IIS/7.5
    Connection: close
           Can any one help me hoe to solve it
    Thanks, Quality Communication Provides Quality Work. Mohammad Siddiqali.

    Hi Matthew ,
                    Thanks for responding .I have reattached the data base but getting trouble shoot as
    The Workstation service has not been started.
    ."Can you tell me why it is showing.
    Thanks, Quality Communication Provides Quality Work. Mohammad Siddiqali.

  • ACE 4710 send Connection:Close when should be Keep-Alive

    After user request to front end http to 10.85.10.4 (default 80) after a port redirect and action list header rewrite
    header rewrite request host header-value http://10[.]85[.]10[.]4 replace http://10.85.10.67:84/jde/E1Menu.maf%1
    I see the request go out (wireshark) to the back-end javaserver but in the Connection it's close not keepalive:
    GET /jde/E1Menu.maf HTTP/1.1
    Connection: Close
    Host:10.85.10.67:84
    After the get from the ACE the jserver replies with the JDE login screen but the ACE ignores it?

    Try by enabling persistence rebalance in an http parameter-map.
    Also your rewrite rule is wrong, you've been mistaken regarding the role of the Host field I guess. What you try to configure in your config is a URL rewrite but it's not supported by the ACE.

  • If I redirect url will database connection close ?

    Can someone tell me how this would work ?
    If I connect to the database and if the username and password is correct I redirect the user to a website using :
    response.sendRedirect(response.encodeRedirectUrl("http:....");
    and then I close the connections...
    rs.close();
    stmt.close();
    connection.close();
    Then if the user is valid will my connection close ? If not how do I close the connection ??

    Right now I have it this way:
    if (rs.next()) {
    response.sendRedirect(response.encodeRedirectUrl("http.........."));
         else
    something else and close connections
         }                         

  • Connection to media server closes autometically

    Hi,
    I have made chat application, it is working fine. but if
    user is idle for some time ,connection is closed .
    how to prevent this, i.e. if user is idle also it should not
    disconnect.
    any one please help me what should i do for this, since many
    days i am trying for this, i could not got any solution.
    thanks in advance
    regards
    avanthika

    I see, as usual, no responses. I have the same problem. Waiting for reply back from Customer support.

  • Which is better to use? connection.close() or connection = null

    Hi,
    can anybody let me know what is the difference between the following statements when intended to end the usage of it?
    finally{
    try{
    if(con != null){
    con.close();
    }catch(Exception e){
    System.out.println("Error in closing connection");
    }OR
    finally{
    con =null;
    }also can i set NULL to Resultset or Prepared statement instead of close() method?
    Please let me know what will be the difference in each case.
    Thanks in Advance.

    Doing this is a BAD idea.
    finally{
       con =null;
    }It's likely to cause your application to completely stop working after a certain number of connections have been acquired and subsequently leaked.
    Always make sure that all database connections are closed after use under all circumstances.

  • [1.2.0.29.98] delete another connection closes all open packages

    Hi,
    there were several package body and header tabs ( edit mode ).
    when i deleted another connection, all of them where closed but the running debugging process is still alive.
    any idea?
    regards, anita

    Anita,
    I used tried this. I had a couple of editors open on hr and a debug session open on hr as well. I had sys open with a couple of editors too.
    Now, When i close Sys, any editors that are using the sys connection AND are not pinned, close. Nothing else closes. This is exactly how this is supposed to work.
    Kevin, Tell me exactly how to reproduce your 'issue' and we'll look into it too. If it is a bug, then it will be logged.
    Barry

  • JCO Connection close

    Hi  All,
    I wanted to know is the connection to close the JCO should be handled in the program or the system will handle since I am using the JCO connection handled by content admin with JCo Pool Configuration.
    <b>I am seeing in SAP backend all the sessions are still open.</b>
    Thanks,
    Rakesh

    Valery,
    We are having an issue wherein the JCo connections are still listed in AL08 output long after the applications are closed. We do call disconnectIfAlive method after executing the Adapative RFC calls.
    Do let me know if there is anyway we can force webdynpro to release connections to the backend or is there any timeout setting in R3 that has to be configured so these connections dont stay open for indefinite time.
    Thanks in advance !

  • Oracle Inactive Connections after connection.close()

    Hi,
    I've the following problem: although I close the oracle connection, the connection is kept inactive (in the oracle enterprise manager console), and after a while the maximum number of connections is reached.
    I'm using the oracle oci8 driver (oracle 9.0.2).
    is there anything else that I need to do to realy close the db connections ?
    thanks,
    Jo�o Portela

    I don't know if this is your problem, but many programmers end up leaking connections by not handling the exceptions correctly.
    You need to be doing something like:
    try
    // get connection
    // do work
    con.commit();
    catch (Exception e)
    LOG.Error("Something bad happened");
    LOG.Error(e)
    finally
    con.close();
    In other words, use finally to gurantee execution of close...

  • Why is firefox sending so many outbound connections, close to 200.

    When I first open Firefox, everything slows down and/or stops. When I check my firewall, it occasionally shows as many as 215 outgoing connections, as much as 95% of which are from Firefox. The OS is Win Vista Home Edition. The firewall is Comodo.

    Hi,
    Please check if this repeats in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode.] Safe Mode disables the installed extensions and plugins in '''Tools''' ('''Alt''' + '''T''') > '''Add-ons'''.
    Please also note that Firefox may open multiple connections per server, so having many tabs open could also be a reason. Firefox may also prefetch content from links in a page while idle.

  • Internet connection closes ITunes--why?

    When I'm connected to the Internet, ITunes shuts down as soon as I try to open it. When I am not connected to the Internet, it opens and works. How can I find out WHY this happens and hopefully CORRECT the problem? I have Windows 7.

    Well if you got a virus that wiped your computer clean, and you had windows reinstalled, Id say windows firewall is blocking you. You may find this artical helpful for you http://docs.info.apple.com/article.html?artnum=300870

  • Launch connection closes with ssh

    We are running solaris 10 using SGDv4.50.907, connecting to a Solaris 8 host, using the ssh protocol. We can open an xterm session via SGD , use the launch string and get the application to appear. When we use SGD directly to attempt the launch, it appears to launch when we see a connection closed.
    The SGD host is running Solaris SSH. This happens using SUN ssh, openssh or fsecure ssh on the client side. Any ideas ? thanks

    So, when you run an "xterm" session through SGD, and run the application command, it works, but trying to run it directly, it fails?
    There are a couple of things that come to mind.
    First, is the applications' "endswhen" property - that is, what behavior tells SGD that the session has ended? If incorrect, it could cause this behavior:
    http://docs.sun.com/source/820-6689/appendix3.html#Z400000c1312851
    Another setting that can cause this is the "Keep Launch Connection Open" not being set.
    http://docs.sun.com/source/820-6689/appendix3.html#Z400000c1316428
    Honestly, I don't even recall the details of when this occurs vs when it doesn't, but I don't really think it's all that important.
    Try varying these properties to see if you get better behavior.
    Failing that, trying increasing the log output from the execpe and see if there's some useful output from the launch process.
    See: http://docs.sun.com/source/820-6689/chapter4.html#Z40003d81350137

Maybe you are looking for

  • XMLP 5.6.2 Generic setup questions

    We have this configuration and wish to get started with XML Publisher: 11.5.9 Linux Production application server 9.2.0.6.0 Linux Production database server 11.5.9 Linux Development/Test (shared) application server 9.2.0.6.0 Linux Development/Test (s

  • Characters not visible in Generated pdf format..

    Hi , I am working on a report.I have created an rdf file and registered in Apps to generate the report output in pdf format.When i am running my concurrent request its generating the pdf file but its not generating any characters only numerical value

  • Post Moved Slow-speeds-after-6-months

    M oved to Infinity board http://community.bt.com/t5/BT-Infinity/Slow-speeds-after-6-months/td-p/767428 If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then pleas

  • How to Sync webgallery to iPhoto???????

    So as I upgraded to leopard i reinstalled iPhoto. Now how can I get .mac web gallery to sync to my clean installation of iPhoto? Is there a way to get the pics uploaded back to my computer? thanks

  • Debugging / applets on websites

    Dear All This is probably a horrifically stupid question, I am trying to add Java code to my website and as expected it doesn't work. However, how do I debug and find out where exactly it's going wrong? When I upload the html to the site it simply sa