I'm Java beginner, but I thought that when using try-catch-finally I don't have to declare the exception using throws SQLException. However if I don't use it the compiler gives me the error: "unreported exception java.sql.SQLException; must be caught or declare to be thrown". I included a catch so I'm not sure why this errors occurs.
public static ResultSet getResultSet ( String query )
{
dbConn = getConnection();
try
{
stmt = dbConn.createStatement( );
ResultSet rs = stmt.executeQuery( query );
return rs;
}
catch (SQLException ex)
{
return null;
}
finally
{
stmt.close();
dbConn.close();
}
}