Connection con;
PreparedStatement ps,p2;
try
{
sqlquery = "...";
ps=con.prepareStatement(sqlquery);
ps.executeUpdate();
// using ps2...some similar process.......
}
catch(SQLException sqlex)
{
System.out.print(sqlex.getMessage());
}
我有一个疑问,是否是
Is it possible to find out the cause of the specific error made out by a query or update such that i can handle the situation other than just displaying the error message at output console (as here) displaying the cause ?
例如:如果pspreparedStatement由于重复输入或ps由于一些外键问题等而出错。那么我应该能够具体分析sql错误using SQLException object
这样我就可以相应地处理,而不仅仅是在输出控制台中显示错误消息
我需要这个的原因是因为我想显示用户在通过 GUI 场景工作时所犯的错误(以防万一:这里是 java swing)他通过分析 SQLException 实例以交互方式所做的任何错误条目......
In short , how to classify errors using a single SQLException instance
对不起,如果这个问题变得模棱两可或愚蠢..!!!