Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Errors and Warnings

Exceptions that may be raised in zxJDBC are the following:

  • Error—This is the generic exception.

  • DatabaseError—Raised for database-specific errors. The connection object and all the connection methods (connect, lookup, conntectx) may raise this.

  • ProgrammingError—Raised for programming errors such as missing parameters, bad SQL statements. The cursor object and the lookup connection may raise this.

  • NotSupportedError—This exception is raised when a method is not implemented.

Each of these exceptions are within the zxJDBC package, so except clauses should look like the following:

>>> try:
...   pass #Assume a method that raises and error is here
... except zxJDBC.DatabaseError:
...   pass # Handle DatabaseError
... except zxJDBC.ProgrammingError:
...   pass # handle ProgrammingError
... except notSupportedError:
...   pass # handle not supported error
... except zxJDBC.Error:
...   pass # Handle the generic Error exception

You can also get warnings with the cursor's warnings attribute. If no warnings exist, then the cursor.warnings attribute is None.

  • + Share This
  • 🔖 Save To Your Account