Java org.hibernate.exception.sqlgrammareexception:执行工作时出错&;
这是我的工作班Java org.hibernate.exception.sqlgrammareexception:执行工作时出错&;,java,xml,hibernate,Java,Xml,Hibernate,这是我的工作班 public class MyWork implements Work { @Override public void execute(Connection con) throws SQLException { CallableStatement cstmt=con.prepareCall("{?=call emp_bonus(?)}"); cstmt.registerOutParameter(1, Types.DOUB
public class MyWork implements Work
{
@Override
public void execute(Connection con) throws SQLException
{
CallableStatement cstmt=con.prepareCall("{?=call emp_bonus(?)}");
cstmt.registerOutParameter(1, Types.DOUBLE);
Scanner s= new Scanner(System.in);
System.out.println("enter employee number");
int eno=s.nextInt();
cstmt.setInt(2, eno);
cstmt.execute();
Double bonus=cstmt.getDouble(1);
System.out.println("Bonus="+bonus);
cstmt.close();
}
}
这是我的测试课
包com.sathya.test
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import com.sathya.util.HibernateUtil;
public class Test {
public static void main(String[] args)
{
SessionFactory factory=HibernateUtil.getSessionFactory();
Session session=factory.openSession();
session.doWork(new MyWork());
session.close();
}
}
**
我犯了个错误
org.hibernate.exception.sqlgrammareexception:执行工作时出错
**您能检查一下这是否正确吗:
CallableStatement cstmt=con.prepareCall("{?=call emp_bonus(?)}");
传递的参数数量与数据库过程相匹配。恐怕这是一个很好的例子:为什么我的代码不工作?