Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #33669

Re: Java Checked Exceptions

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Java Checked Exceptions
Date 2016-02-08 13:30 +0100
Message-ID <dhrg2nFakleU1@mid.individual.net> (permalink)
References (3 earlier) <56b601cc$0$23722$e4fe514c@news.xs4all.nl> <n97i1i$6f3$1@news.albasani.net> <exceptions-20160207150503@ram.dialup.fu-berlin.de> <dhppanFsdrtU1@mid.individual.net> <25c9bda0-2d07-4339-a7cd-2b868584117d@googlegroups.com>

Show all headers | View raw


On 07.02.2016 23:39, boxzou@gmail.com wrote:
> On Sunday, 7 February 2016 15:56:15 UTC-5, Robert Klemme  wrote:
>> On 07.02.2016 15:09, Stefan Ram wrote:
>>
>>>     Some methods can't know all their exceptions at
>>>     documentation time because they call other methods that
>>>     are only determined at runtime. But this is also the case
>>>     where checked exceptions are difficult to use.
>>
>> How should that be possible?  Can you show an example where not all
>> checked exceptions can be determined at documentation time (i.e. after
>> successful compiling)?

> under JPA, you can plug in Oracle DB, Derby DB, IBM DB2.  Each db
> throws different kinds of exception although they are all subclasses
> of SQLException.  Theoretically you can also plug in Google big table
> which does not throw SQLException at all, or some other things.
> There is no way JPA API can document all these exceptions!

Well, the API documents SQLException so from a caller's perspective he 
knows what to catch - and there won't be any exception thrown that could 
escape that catch.  If anything I'd rather argue that the design of JDBC 
has the flaw to not distinguish basic classes of errors that can surface 
and declare them as checked exceptions, for example:
  - syntax errors in SQL executed (this could even be considered a 
runtime exception because it is a coding error of some sort)
  - communication issues with a remote database server
  - constraint violations
  - resource issues, e.g. database server cancels an SQL statement 
because it uses too many resources (time, memory, IO)

And you use JPA to abstract the concrete database model used so it would 
be very unwise to start writing catch clauses for all sorts of database 
specific exceptions (apart from the fact that this is often not possible 
because you add JDBC drivers at deployment time so the compiler does not 
see them).  So it is practically not possible (even with unchecked 
exceptions!) and it is not wise from a modularity point of view.  And it 
is not needed since you usually get all the details of nested exceptions 
in an application's log.

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 07:18 -0800
  Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 08:15 -0800
    Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-04 17:57 +0100
      Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 10:09 -0800
        Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-04 21:01 +0100
          Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 12:14 -0800
          Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-04 15:16 -0500
            Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-04 21:37 +0100
              Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 13:08 -0800
                Re: Java Checked Exception is BAD! 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-04 21:16 +0000
                Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 13:28 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-04 23:11 +0000
                Re: Java Checked Exception is BAD! a.laforgia@gmail.com - 2016-02-05 04:21 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-05 13:07 +0000
              Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-04 18:04 -0500
                Re: Java Checked Exception is BAD! Gene Wirchenko <genew@telus.net> - 2016-02-05 11:40 -0800
          Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-04 23:22 +0100
          Re: Java Checked Exception is BAD! ruben <ceo@iran.gov> - 2016-02-15 11:45 +0000
      Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 11:57 -0800
        Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-04 21:07 +0100
    Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 11:10 -0800
      Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-04 11:28 -0800
        Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 11:33 -0800
          Re: Java Checked Exception is BAD! 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-04 21:08 +0000
          Re: Java Checked Exception is BAD! Lew <lewbloch@gmail.com> - 2016-02-04 16:09 -0800
  Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-04 12:00 -0500
  Re: Java Checked Exception is BAD! Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-04 19:28 +0100
    Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 11:15 -0800
      Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-04 14:51 -0500
  Re: Java Checked Exception is BAD! 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-04 21:07 +0000
    Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 14:36 -0800
      Re: Java Checked Exception is BAD! a.laforgia@gmail.com - 2016-02-05 05:28 -0800
  Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 15:31 -0800
    Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-05 08:20 -0500
      Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-05 08:25 -0800
        Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-05 08:47 -0800
          Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-05 16:09 -0800
            Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-06 08:38 -0500
              Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-06 14:13 +0000
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-06 15:23 +0100
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-07 14:49 +0100
                Re: Java Checked Exceptions Robert Klemme <shortcutter@googlemail.com> - 2016-02-07 21:55 +0100
                Re: Java Checked Exceptions boxzou@gmail.com - 2016-02-07 14:39 -0800
                Re: Java Checked Exceptions Robert Klemme <shortcutter@googlemail.com> - 2016-02-08 13:30 +0100
                Re: Java Checked Exceptions boxzou@gmail.com - 2016-02-08 06:14 -0800
                Re: Java Checked Exceptions Robert Klemme <shortcutter@googlemail.com> - 2016-02-08 20:55 +0100
                Re: Java Checked Exceptions Lew <lewbloch@gmail.com> - 2016-02-08 16:06 -0800
                Re: Java Checked Exceptions boxzou@gmail.com - 2016-02-08 18:38 -0800
                Re: Java Checked Exceptions Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-09 12:15 +0000
                Re: Java Checked Exceptions boxzou@gmail.com - 2016-02-09 04:59 -0800
                Re: Java Checked Exceptions Lew <lewbloch@gmail.com> - 2016-02-10 12:13 -0800
                Re: Java Checked Exceptions boxzou@gmail.com - 2016-02-10 19:00 -0800
                Re: Java Checked Exceptions Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-11 12:18 +0000
                Re: Java Checked Exceptions leif.roar@dimnakorr.com - 2016-02-11 04:43 -0600
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:34 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:11 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-07 23:19 +0000
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 15:42 -0800
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-06 09:43 -0500
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:14 -0800
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-08 09:22 -0500
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 11:01 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 11:08 -0800
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-08 22:02 +0100
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:09 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-07 23:29 +0000
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-08 21:49 +0100
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-08 17:23 -0500
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 18:46 -0800
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-09 08:21 +0100
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-09 04:58 -0800
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-09 08:17 -0500
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-09 07:57 -0800
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-10 02:37 +0100
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-10 18:58 -0800
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-11 08:13 -0500
                Re: Java Checked Exception is BAD! Lew <lewbloch@gmail.com> - 2016-02-11 14:02 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-11 16:41 -0800
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-10 02:31 +0100
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-10 18:47 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-09 12:26 +0000
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-09 04:57 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-09 18:27 +0000
              Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 20:19 -0800
            Re: Java Checked Exception is BAD! Robert Klemme <shortcutter@googlemail.com> - 2016-02-06 16:01 +0100
              Re: Java Checked Exception is BAD! 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 15:10 +0000
                Re: Java Checked Exception is BAD! Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2016-02-06 17:59 -0800
                Re: Java Checked Exception is BAD! 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-07 09:34 +0000
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:23 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 20:52 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 21:13 -0800
              Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-07 14:19 -0800
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-07 23:42 +0000
                Re: Java Checked Exception is BAD! Robert Klemme <shortcutter@googlemail.com> - 2016-02-08 13:17 +0100
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 04:39 -0800
                Re: Java Checked Exception is BAD! Lew <lewbloch@gmail.com> - 2016-02-08 16:05 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 18:35 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 19:10 -0800
                Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-08 19:12 -0800
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-11 16:37 +0100
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-11 12:00 -0500
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-11 19:01 +0100
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-11 20:32 +0100
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-11 15:20 -0500
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-11 23:53 +0100
                Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-11 18:21 -0500
                Re: Java Checked Exception is BAD! Lew <lewbloch@gmail.com> - 2016-02-11 15:45 -0800
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-12 01:19 +0100
                Re: Java Checked Exception is BAD! Lew <lewbloch@gmail.com> - 2016-02-11 19:18 -0800
                Re: Java Checked Exception is BAD! Sebastian <news@seyweiler.dyndns.org> - 2016-02-12 08:31 +0100
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-12 15:33 +0100
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-12 15:41 +0100
                Re: Java Checked Exception is BAD! Silvio <silvio@internet.com> - 2016-02-12 15:42 +0100
                Re: Java Checked Exception is BAD! Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-08 21:19 +0000
        Re: Java Checked Exception is BAD! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-02-05 13:00 -0500
  Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 15:51 -0800
    Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 15:59 -0800
      Re: Java Checked Exception is BAD! boxzou@gmail.com - 2016-02-04 16:03 -0800
    Re: Java Checked Exception is BAD! Eric Douglas <e.d.programmer@gmail.com> - 2016-02-05 05:33 -0800
  Re: Java Checked Exception is BAD! Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2016-02-04 21:05 -0800
  Re: Java Checked Exception is BAD! ynseo <yeori.seo@gmail.com> - 2016-02-08 01:05 -0800
  Re: Java Checked Exception is BAD! Sebastian <sebastian.millies@softwareag.com> - 2016-02-19 03:43 -0800

csiph-web