MySQL与PSQLException的等价物是什么

MySQL与PSQLException的等价物是什么,mysql,postgresql,Mysql,Postgresql,我正在尝试将我的数据库和web应用程序从PostgreSQL移动到MySQL,该应用程序使用Play2.3.0 我让应用程序与MySQL一起工作,但我还没有进行错误管理,我需要您的帮助: 原始代码使用PSQLException,如下所示: import org.postgresql.util.PSQLException try { SQL("DELETE FROM Lab WHERE id = {id}") .on("id" -> lab.id)

我正在尝试将我的数据库和web应用程序从PostgreSQL移动到MySQL,该应用程序使用Play2.3.0

我让应用程序与MySQL一起工作,但我还没有进行错误管理,我需要您的帮助:

原始代码使用PSQLException,如下所示:

import org.postgresql.util.PSQLException

try {
      SQL("DELETE FROM Lab WHERE id = {id}")
        .on("id" -> lab.id)
        .executeUpdate()
      true
    } catch {
      case e: PSQLException
        if e.getMessage.contains("update or delete on table \"lab\" violates foreign key constraint \"conference_organizedby_fkey\" on table \"conference\"") |
           e.getMessage.contains("update or delete on table \"lab\" violates foreign key constraint \"appuser_lab_fkey\" on table \"appuser\"")
        => Logger.warn(e.getServerErrorMessage.getMessage); false
    }
我找不到最适合这种类型错误的MySQL错误处理程序

您认为我应该使用什么?

只需捕获,其中
PSQLException
是一个实现,并坚持其方法,即
getMessage()

除非您确实需要PSQLException提供的额外信息,否则最好不要知道异常的实际类,因为这样您就可以不可见地将处理程序绑定到JDBC连接路径