JDBC call not executing
- by dbyrne
I am working on one of the DAOs for a medium sized web application. Unfortunately, it contains very convoluted logic, and makes hundreds of JDBC stored proc calls in loops. This is out of my control. I am working on a method inside the DAO which makes a single JDBC call. The simplified version of what this method looks like is this:
DriverManager.registerDriver(new com.sybase.jdbc2.jdbc.SybDriver());
Connection con = DriverManager.getConnection((String)connectionDetails.get("DATABASE_URL")
(String)connectionDetails.get("USERID"),
(String)connectionDetails.get("PASSWORD"));
String sqlToExecute = "{call " + STORED_PROC + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
CallableStatement stmt = con.prepareCall(sqlToExecute);
//Maybe I should try calling clearParameters here?
stmt.setString(1,someData);
//....Set of parameters....
if (!stmt.execute()) {
//execute method never returns false
}
stmt.close();
Its pretty much a textbook JDBC call. All this stored proc does is insert a single row. Here is where things get crazy:
This code works when you run it through a debugger line by line, but fails when you run it "full speed". Not only does it fail, but it doesn't throw any exception! The execute method always returns true. It just breezes right through the JDBC call without inserting a row to the database. If you go through the log files, copy the stored proc call and run it manually, it works (just like it does in debug mode).
Whats strange is that the rest of the DAO, with all its hundreds of looped stored proc calls, works fine. My thinking is that Connection or CallableStatement is caching some value behind the scenes that is screwing things up.
Has anyone ever seen anything like this before? A JDBC call failing with no exceptions? I know it will be impossible to provide a complete solution to this without seeing the whole application, I am just looking for suggestions on possible issues to investigate.