2

i want to call saved sql procedure from java using ebean. i am using this code:

String sql = "call copy_lov_Countries(?)";
CallableSql cs = Ebean.createCallableSql(sql);
cs.registerOut(1, Types.INTEGER);
Ebean.execute(cs);

It reaches the procedure but it does not run right. it never copies any data!!

any idea??

1
  • 1
    What DBMS are you using? Oracle? Commented Dec 8, 2014 at 7:57

2 Answers 2

1

Try this Integer returnValue = (Integer) cs.getObject(1); after Ebean.execute(cs); And post it here What it gives ?

Update :Make the follwing changes to your code

Ebean.beginTransaction();  
try {  
String sql = "call copy_lov_Countries(?)";
CallableSql cs = Ebean.createCallableSql(sql);
cs.registerOut(1, Types.INTEGER);
Ebean.execute(cs);

 } finally {  
   Ebean.endTransaction();  
}  
Sign up to request clarification or add additional context in comments.

2 Comments

i did. but same thing no data is copied.
it returns the number 13 . which is the number of rows that should be inserted in the table. however the table is empty!!
1

Try this:

String sql = "CALL copy_lov_Countries(:param)";
CallableStatement statement = connection.prepareCall(sql);
statement.registerOutParameter("param", Types.INTEGER);
statement.execute();
connection.commit();

The code works with Oracle, should work also with MySQL. The principle is same.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.