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: (view raw or whole 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(
	at org.postgresql.Connection.ExecSQL(
	at org.postgresql.jdbc2.Statement.execute(
	at org.postgresql.jdbc2.Statement.executeQuery(

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

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);
		// This shows a wait dialog
          VmGuiWaitDialog dialog = new VmGuiWaitDialog("Executing query
......???", new JFrame(),true);
		// checks if cancel clicked or by any chance Thread
          if(dialog.isInterrupted() || execThread.isInterrupted()){
      }catch(Exception e){

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

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

-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-2015 The PostgreSQL Global Development Group