Look at the following code:
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection
("jdbc:oracle:thin@localhost:1521:xe", "system", "java");
}
catch (ClassNotFoundException cnf) {
cnf.getMessage();
}
finally
{
con.close();
}
return(result);
Every time the code is executed the
finally
block is executed. It is there to clean up after a
try
block and is executed irrespective of if there has been an exception or not.
So after opening a DB connection you close it.
Also, even though it's not used,
result
is not being set.