IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32020


Ignore:
Timestamp:
Aug 3, 2011, 4:26:56 PM (15 years ago)
Author:
rhenders
Message:

using exception-handling to check connection is ok; setting everythingOK to False if it fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/mysql.py

    r31844 r32020  
    3636        # set up JDBC connection
    3737        self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?user="+self.dbUser+"&password="+self.dbPass
    38         self.con = DriverManager.getConnection(self.url)
    39         self.connectionID = self.getLastConnectionID()
    40         self.logger.debug("MySQL connection to %s with ID %d" % (dbType, self.connectionID))
    41 
    42         #self.stmt = self.con.createStatement()
     38        try:
     39            self.con = DriverManager.getConnection(self.url)
     40            self.connectionID = self.getLastConnectionID()
     41            self.logger.debug("MySQL connection to %s with ID %d" % (dbType, self.connectionID))
     42        except:
     43            self.logger.error("Unable to connect to " + self.url)
     44            self.everythingOK = False
     45            return
     46
     47        self.everythingOK = True
    4348
    4449
Note: See TracChangeset for help on using the changeset viewer.