import java java.lang.Class.forName('org.postgresql.Driver') try: con= java.sql.DriverManager.getConnection('jdbc:postgresql:skdb', 'admin', '') # raise an SQLException because I have no postgres server except java.sql.SQLException, e: print 'Caught SQLException' print 'Class:', e.getClass().getName() # print Class: org.postgresql.util.PSQLException print 'Base class:', e.getClass().getSuperclass().getName() # print Base class: java.sql.SQLException else: print 'UnCaught'