try{
Statement stmt = conn.createStatement();
stmt.execute("CREATE OR REPLACE FUNCTION log(p_user IN VARCHAR2, p_password IN VARCHAR2, p_name IN VARCHAR2 ) "
+ "RETURN number "
+ "IS "
+ "flag login%ROWTYPE; "
+ "temp number; "
+ "BEGIN "
+ "select username into flag "
+ "from login "
+ "where username=p_user and password=p_password and name=p_name; "
+ "IF (sql%found) THEN temp:= 1; "
+ "ELSE temp:= 0; "
+ "END IF; "
+ "return temp; "
+ "END; ");
stmt.close();
String value = Combo_Name.getSelectedItem().toString();
String sql= "begin "
+ "?:=log(?,?,?); "
+ "end; ";
CallableStatement cstmt = conn.prepareCall (sql);
cstmt.registerOutParameter (1, OracleTypes.NUMBER);
cstmt.setString(2, user_id.getText());
cstmt.setString (3, password.getText());
cstmt.setString(4, value);
cstmt.execute();
int check =cstmt.getInt(1);
if(check==1)
{
JOptionPane.showMessageDialog(null, "Login Successful");
}
else
{
JOptionPane.showMessageDialog(null, "Invalid Username or Password");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
我在调用函数时显示pls-00306
错误。每次显示错误的类型或数量的参数。请帮我解决错误。变量值用于从组合框中获取输入。