File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Callable statement return false on execute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Callable statement return false on execute" Watch "Callable statement return false on execute" New topic

Callable statement return false on execute

marie menetrieux

Joined: Aug 07, 2003
Posts: 2
I have a problem with a callable statement, the execute always return false whereas the procedure called work fine in sql+
If you have any idea please tell me ...

the procedure is :
tr_id NUMBER;
tr_id :=2;

the simplified class is :

public class testcall {
private static Connection myConnection;
public static void main(String[] args) {
System.out.println("debut test");
myConnection = DriverManager.getConnection("jdbc racle:thin:@bermudes:1521:EAGLE","training", "training");
boolean resExec = true;
String end_date_query = "{ call training.pck_user_job.test }";
CallableStatement cStmt = myConnection.prepareCall(end_date_query);

resExec = cStmt.execute();
System.out.println("updateUserJob ben alors ? "+resExec);
}catch(Exception e){
System.out.println("pb "+e);
marie menetrieux

Joined: Aug 07, 2003
Posts: 2
In fact I found the solution, after one day of searches, in an other forum. I was wrong in the interpretation of the boolean returned by execute :
"I have no idea what SQL you are executing, but in the Java documentation it says;
true if the next result is a ResultSet object; false if it is an update count or there are no more results
So, if you are doing an insert, then the return would always be false.
If you want to know if you were successfull with your insert, you can use executeUpdate instead. This will return the number of rows that were updated, so if it's > 0 then you were succesful. "
may be it will help other people
I agree. Here's the link:
subject: Callable statement return false on execute
It's not a secret anymore!