closing connection while cancelling

Поиск
Список
Период
Сортировка
Искать

closing connection while cancelling

От:
Chitta Barik <Chitta.Barik@genband.com>
Дата:
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 Queryprivate 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




FAQ