Changeset 33787 for trunk/ippToPsps/jython/mysql.py
- Timestamp:
- Apr 16, 2012, 12:18:37 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/mysql.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/mysql.py
r33780 r33787 34 34 self.dbPass = config.getDbPassword(dbType) 35 35 36 # a user friendly connection sring 37 connectionStr = self.dbName + "@" + self.dbHost 38 36 39 # set up JDBC connection 37 40 self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?autoReconnect=true&user="+self.dbUser+"&password="+self.dbPass … … 39 42 self.con = DriverManager.getConnection(self.url) 40 43 self.connectionID = self.getLastConnectionID() 41 self.logger. debug("MySQL connection to %s with ID %d" % (dbType, self.connectionID))44 self.logger.infoPair("Connected to MySQL Db", connectionStr) 42 45 except: 43 self.logger.error("Unable to connect to " + self.url) 44 self.everythingOK = False # TODO need this? 46 self.logger.errorPair("Unable to connect to", connectionStr) 45 47 self.connected = False 46 return 47 48 self.everythingOK = True 48 raise 49 49 50 self.connected = True 50 51 … … 251 252 except: pass 252 253 #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'") 254 255 ''' 256 Checks that we have a connection 257 ''' 258 def isConnected(self): 259 260 try: 261 self.con 262 self.connected = True 263 except: 264 self.logger.errorPair("Not connected to", self.url) 265 self.connected = False 266 267 return self.connected 268 253 269 ''' 254 270 TODO 255 271 ''' 256 272 def execute(self, sql): 273 274 if not self.isConnected(): raise 257 275 258 276 stmt = self.con.createStatement() … … 265 283 def executeQuery(self, sql): 266 284 285 if not self.isConnected(): raise 286 267 287 stmt = self.con.createStatement() 268 288 rs = stmt.executeQuery(sql)
Note:
See TracChangeset
for help on using the changeset viewer.
