R
Rhino
I've got a compiler warning that has me quite baffled.
Here is my code:
if (sqlCode != 0 || !sqlState.equals("00000")) {
System.err.println("Stored procedure " + STORED_PROCEDURE_NAME + "
failed.");
System.err.println("SQLState = " + sqlState);
System.err.println("SQLCode = " + sqlCode);
System.err.println("SQLMessage = " + sqlMessage);
System.err.println("ProcMessage = " + procMessage);
System.err.println("StackTrace:\n" + stackTrace);
try {
conn01.rollback();
}
catch(SQLException sql_excp) {
System.err.println(CLASS_NAME + "." + METHOD_NAME + " - Encountered error
while " +
"attempting to roll back.");
sql_excp.printStackTrace();
}
finally {
return;
}
}
and here is the warning:
finally block does not complete normally
I don't have much experience with finally but, as far as I can tell, I'm not
doing anything odd here. If I get an error from my database call, I want to
print some diagnostics and attempt to rollback the transaction, then return
from the method. If the rollback fails, I want to print some additional
diagnostics and, again, return from the method.
Is there a problem with doing a return in a finally block? If there is some
sort of problem with my approach, can anyone suggest an alternative way of
accomplishing the same thing?
I'm running Eclipse 3.0.1 on Windows XP.
--
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare
Here is my code:
if (sqlCode != 0 || !sqlState.equals("00000")) {
System.err.println("Stored procedure " + STORED_PROCEDURE_NAME + "
failed.");
System.err.println("SQLState = " + sqlState);
System.err.println("SQLCode = " + sqlCode);
System.err.println("SQLMessage = " + sqlMessage);
System.err.println("ProcMessage = " + procMessage);
System.err.println("StackTrace:\n" + stackTrace);
try {
conn01.rollback();
}
catch(SQLException sql_excp) {
System.err.println(CLASS_NAME + "." + METHOD_NAME + " - Encountered error
while " +
"attempting to roll back.");
sql_excp.printStackTrace();
}
finally {
return;
}
}
and here is the warning:
finally block does not complete normally
I don't have much experience with finally but, as far as I can tell, I'm not
doing anything odd here. If I get an error from my database call, I want to
print some diagnostics and attempt to rollback the transaction, then return
from the method. If the rollback fails, I want to print some additional
diagnostics and, again, return from the method.
Is there a problem with doing a return in a finally block? If there is some
sort of problem with my approach, can anyone suggest an alternative way of
accomplishing the same thing?
I'm running Eclipse 3.0.1 on Windows XP.
--
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare