This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC 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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Callable statement return false on execute" Watch "Callable statement return false on execute" New topic
Author

Callable statement return false on execute

marie menetrieux
Greenhorn

Joined: Aug 07, 2003
Posts: 2
Hello
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 ...
thanks

the procedure is :
PROCEDURE test IS
tr_id NUMBER;
BEGIN
tr_id :=2;
END;
-----

the simplified class is :

public class testcall {
private static Connection myConnection;
public static void main(String[] args) {
System.out.println("debut test");
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
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();
cStmt.close();
System.out.println("updateUserJob ben alors ? "+resExec);
}catch(Exception e){
System.out.println("pb "+e);
}
}
}
marie menetrieux
Greenhorn

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;
Returns:
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: http://aspose.com/file-tools
 
subject: Callable statement return false on execute
 
Similar Threads
Problem calling IN parameters Stored Procedure from Java
DriverManager error
problem updating fields on an access db
PL/SQL and JDBC
WebLogic - SSL