the getConnection of the DataSource throws SQLException[1], which would be wrapped with HibernateException. So, you should look at
the cause and make out whether the username/password is correct. For example:
try{
session.saveOrUpdate(object);
} catch(HibernateException e) {
Throwable cause = e.getCause();
if(cause instanceof SQLException) {
SQLExeption sqlEx = (SQLException) cause;
// check the vendor code/sql state to identify the login/password is correct.
}
}
[1]
http://www.mchange.com/projects/c3p0/ap ... ang.String,
java.lang.String)