| 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
|
 |
 |
|
|
subject: Callable statement return false on execute
|
|
|