jython and java exceptions

Jan Gregor gregor.jan at NOSPAMquick.cz
Wed Aug 11 06:26:06 EDT 2004


Hello
>
I tried it again with SQLException only but my main loop ends with
uncatched com.sybase.jdbc2.jdbc.SybSQLException.
>
This is extract from my code, exception is thrown by self.db.executeSql(iline),


   def run (self):
       while (1):
           gr_mode= 0
           iline= Readline.readline(":", 0)
           if iline==None:
               continue
           iline= strip(iline)
           if iline=='\q':
               try:
                   Readline.writeHistoryFile(self.rl_history.getName())
               except:
                   print ("Error writing history file!")
               System.exit(0)
               break
           if iline=='\gr':
               continue
>
           Readline.addToHistory(iline)
>
           if re.match(r'^\+ ', iline):
               gr_mode= 1
               iline= strip(iline[2:])
>
           try:
               type, result= self.db.executeSql(iline)
               if result==None:
                   continue
               if type=='resultSet':
                   self.process(result)
               elif type=='table':
                   if gr_mode:
                       wnd = swingWnd.SimpleSwing(result.to_html())
                       wnd.size= (600,600)
                       wnd.setVisible(1)
                   else:
                       self._print_table(result)
               elif type=='viewSource' or type=='procSource':
                   self.println(result)                      
               elif type=='tableDesc':
                   self._print_table(result)
               elif type=='error':
                   self.println(result)
           # except (SQLException, PSQLException, SybSQLException), e:
           except java.sql.SQLException, e:
               self.println(e.getMessage())
#            except:
#                pass

Jan



More information about the Python-list mailing list