I am trying to connect to mysql database using JDBC. I have applied exception handling. However simply printing exception object is amateur. I want to know exact reason of exception.
For example, if I give wrong hostname it should give me exception that Hostname was incorrect.
How to go about it ?
SQLException has method getErrorCode() that returns a vendor-specific error code that indicates what exactly went wrong. Combined with getMessage() and possibly getSQLState() that's all the info you have.