【发布时间】:2012-07-07 11:15:44
【问题描述】:
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 这样我就可以进行相应的处理,而不仅仅是在输出控制台中显示错误消息
我需要这个的原因是因为我想通过分析 SQLException 实例以交互方式显示用户通过 GUI 场景工作(以防万一:这里是 java swing)所做的任何错误条目。 ..
In short , how to classify errors using a single SQLException instance
对不起,如果这个问题模棱两可或愚蠢..!!!
【问题讨论】:
标签: java sql jdbc prepared-statement sqlexception