我想在commit.where之前放置if else或switch语句更适合检查员工数量。我把我的if else或switch代码。如果计数为5,我希望限制员工,然后显示消息“达到最大员工限制”,否则允许提交。 我是java的新人plz有人帮我解决这个问题
public String cmdSave_action()
{
// my code before
{
DeptSet result;
try {
dbo.connect();
result =
dbo.execSQL("select count(*) from empmasterinfo where mainid='ORGElement' and designationid='?') "
(inputText_ORGElement.getValue() != null ?
""));
result = dbo.execSQL(sSQL);
catch (Exception e) {
System.out.println(e.getMessage());
finally
{
dbo.close();
}
return null;
}}}
// my code above
{
Global.PerformIteratorAction(this.bindings, "Commit");
AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
afContext.getProcessScope().put("EmployeeID",
Global.getCurrRowFieldValue("EmpmasterinfoViewIterator",
"Employeeid"));
if (afContext.getProcessScope().get("AddEdit").toString().equals("0"))
{
Global.PerformIteratorAction(this.bindings,
"EPR_TRANSFER_APPLICANT_INFO");
Global.PerformIteratorAction(this.bindings, "eprGenerateApPlan");
}
return null;
}}
我的错误日志
Error(149,12): 'try' without 'catch' or 'finally'
Error(154,36): , expected
Error(157,34): field SQL not found in class hcm.view.backing.empprofile.EmployeeMasterInfo_Add
Error(159,11): illegal start of expression
Error(159,11): ; expected
E:\HCM\ViewController\src\hcm\view\backing\empprofile\dbo.java
Error(13,16): method does not return a value
答案 0 :(得分:0)
答案 1 :(得分:0)
catch
和finally
位于try block
try {
//code
}
catch(Exception e) {
System.out.println(e.getMessage());
}
finally {
dbo.close();
}
答案 2 :(得分:0)
使用IDE可以帮助您在编写代码时进行缩进和正确格式化。例如Eclipse。
对于第一个错误,请关闭try-catch块
对于第二个错误:由于您的方法声明为public String cmdSave_action()
,因此您应该在方法的末尾返回String
值。您的代码中缺少return
语句。