How to return SQL error Message

I am a new hibernate java programmer. I have developed a small application with PostgreSQL. My problem is that when I try to delete a record used through a foreign key, the exception message just say “Could not execute statement”. I noticed in the console window that much more information is sent such as :
org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) ERROR: update or delete on table “AdminSite” violates foreign key constraint “FK_AdminUserSite” on table “AdminUserProfile”
Detail: Key (STCode)=(HO ) is still referenced from table “AdminUserProfile”.

I want to retrieve and display this message. How can it be made as it is not an exception ?