Skip site navigation (1) Skip section navigation (2)

closing connection while cancelling

From: Chitta Barik <Chitta(dot)Barik(at)genband(dot)com>
To: "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgresql(dot)org>
Subject: closing connection while cancelling
Date: 2001-11-21 15:50:37
Message-ID: AB209393C95AD411961600D0B7819F6C03D02CE1@gbexc.genband.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
hi all,

I am first time using PostgreSQL with Java and having some problem while
cancelling the executing query.

I am using JDBC Driver 7.0-1.2 . And i am accessing database from a GUI [
Swing based application ]. The problem is

" When an end user executes a query i am showing a wait dialog till the
query returns results. If the user clicks on "Cancel" in between then I am
getting following exception after that connection dies to the database. I
don't have any other option than closing the application and restarting it
again "

Here is the exception.
"The backend has broken the connection. Possibly the action you have
attempted has caused it to close.
	at org.postgresql.PG_Stream.ReceiveChar(PG_Stream.java:178)
	at org.postgresql.Connection.ExecSQL(Connection.java:340)
	at org.postgresql.jdbc2.Statement.execute(Statement.java:273)
	at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
	...........
"

I have some debugging statement which prints the connection object itself.
But the object is not null that means the connection has not broken but i
could see the above exception. 


Hope you understood my problem. and reply at the earliest will be
appreciated.

Environment :-

GUI 				:- Swing Based Application
OS  				:- Solaris
JDBC Driver version 	:- 7.0-1.2

Below you can have a look at my client code. If you want i can send my
ConnectionManager code too.

 // This is the starting point for where execution starts

 // Query -> SQL Query
 private void executeQuery(String query){
      ExecuteThread execThread = new ExecuteThread(query);
      try{
          execThread.start();
		// This shows a wait dialog
          VmGuiWaitDialog dialog = new VmGuiWaitDialog("Executing query
......???", new JFrame(),true);
          dialog.show();
		// checks if cancel clicked or by any chance Thread
interrupted.
          if(dialog.isInterrupted() || execThread.isInterrupted()){
               execThread.interrupt();
           }
      }catch(Exception e){
      }
  }


    class ExecuteThread extends Thread{
        String query = null;
        public ExecuteThread(String query){
            this.query = query;
        }
        public void run(){
            try{
		    // This is the class from where user gets a Connection
to the database.
                VmGuiCtQueryResults resultObj =
VmGuiCtQueryResults.getInstance();

		    // This method executes the query using Statement object
                Vector result = resultObj.getQueryResultsList(query);
                if(result != null && result.size() > 0){
                }else {
                    dialog.setVisible(false);
                    VmGuiInfoDialog dlg = new
VmGuiInfoDialog(NO_RESULTS_FOUND,new JFrame());
                    dlg.show();
                }
            }catch(Exception e){
            }
        }
    }



thanks,
-chitta barik




pgsql-interfaces by date

Next:From: Joe ConwayDate: 2001-11-21 17:04:41
Subject: Re: [PATCHES] PQescapeBytea documentation patch
Previous:From: Patrick WelcheDate: 2001-11-21 12:25:55
Subject: Re: [PATCHES] PQescapeBytea documentation patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group