Hello,

Let me to say what I think on that topic.
Guys If you don't know how to handle exception for a given method then
you are better off simply throwing it. Just add it to the method
declaration. That's all about that.
Handle only exceptions in case you are know for sure how to deal with
a failure/error.

In some cases you can simply wrap an exception into RuntimeException.
It sounds like you convert it to an error intentionally. kinda
exception handling. It makes sense for wealth of situations.

Don't write useless boilerplate code that in many cases is cause of an
error. Keep the things as simple as there are.

alexander

On Aug 18, 4:55 am, Christian Catchpole <christ...@catchpole.net>
wrote:
> No, i just let that go up.  I really try to avoid the declare as null
> then set thingy.
>
> On Aug 18, 12:03 pm, Casper Bang <casper.b...@gmail.com> wrote:
>
> > You neglect to handle the checked exception declared by
> > prepareStatement no?
>
> > PreparedStatement stmt = null;
> > try{
> >     stmt = connection.prepareStatement(sql);
> >     final ResultSet rs = stmt.executeQuery();
> >     try{
> >         while (rs.next()){
> >             // Stuff...
> >         {
> >     }
> >     finally{
> >         rs.close();
> >     }}
>
> > catch(SQLException e){
> >     // Logging...}
>
> > finally{
> >     try{
> >         stmt.close();
> >     }
> >     catch(SQLException whoTheFuckCares){
> >     };
>
> > }
>
> > Really, how many other ways are there to do it I wonder now? (Apart
> > from wrapping certain things, like the last try-catch clause in some
> > general purpose "closer util"?).
>
> > /Casper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to