0
在的時候,如果條件不滿足即當達到過程else塊下面的代碼成功運行其他拋出閉聲明例外:這段代碼中的錯誤在哪裏?
public synchronized void create(Map formMap) throws SQLException, Exception
{
CallableStatement callStmt=null;
try
{
String sql= "BEGIN UP_I_51(?, ?, ?, ?, ?, ?, ?, ?, ?); END;";
callStmt=getConnection().prepareCall(sql);
callStmt.setString(1,formMap.get("periodFrom").toString());
callStmt.setString(2, formMap.get("periodTo").toString());
String srcType=formMap.get("srcType").toString();
callStmt.setString(3, srcType);
callStmt.setString(4, formMap.get("collabIdMod").toString());
callStmt.setString(5, formMap.get("name").toString());
callStmt.setString(6, formMap.get("address").toString());
callStmt.setString(7, " ");
String parCollabId=formMap.get("pCollabId").toString();
if(StringUtils.exists(parCollabId))
{
callStmt.setString(8, parCollabId);
String parSrcType=getParentSrcType(srcType);
callStmt.setString(9, parSrcType);
}
else
{
callStmt.setString(8, " ");
callStmt.setString(9, " ");
}
callStmt.executeUpdate();
}
finally
{
callStmt.close();
}
}
我換成下面的代碼的代碼,它現在正在工作。我以前在設置字符串時使用了條件,但不知道爲什麼現在會出現異常。
我還是不明白,爲什麼這個異常來。任何人都可以找到它?
public synchronized void create(Map formMap) throws SQLException, Exception
{
CallableStatement callStmt=null;
String srcType=formMap.get("srcType").toString();
String parCollabId=formMap.get("pCollabId").toString();
String parSrcType=getParentSrcType(srcType);
try
{
srcType=formMap.get("srcType").toString();
parCollabId=formMap.get("pCollabId").toString();
parSrcType=getParentSrcType(srcType);
parCollabId = StringUtils.exists(parCollabId) ? parCollabId : " ";
parSrcType = StringUtils.exists(parCollabId) ? parSrcType : " ";
String sql= "{ call UP_I_51(?, ?, ?, ?, ?, ?, ?, ?, ?) }";
callStmt=getConnection().prepareCall(sql);
callStmt.setString(1,formMap.get("periodFrom").toString());
callStmt.setString(2, formMap.get("periodTo").toString());
callStmt.setString(3, srcType);
callStmt.setString(4, formMap.get("collabIdMod").toString());
callStmt.setString(5, formMap.get("name").toString());
callStmt.setString(6, formMap.get("address").toString());
callStmt.setString(7, " ");
callStmt.setString(8, parCollabId);
callStmt.setString(9, parSrcType);
callStmt.executeUpdate();
}catch(Exception e)
{
e.printStackTrace();
throw e;
}
finally
{
callStmt.close();
}
}
當人們將能夠告訴的錯誤和*功能*之間的區別? – 2011-03-31 01:26:20
@Muntoo:I;新來的Java,所以我不知道,請幫幫我! – sriram 2011-03-31 01:30:39
我在開玩笑......真是個壞玩笑。 – 2011-03-31 01:32:24