Results 1 to 3 of 3

Thread: why do JDBC lines of code require a try/catch block be provided. ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    why do JDBC lines of code require a try/catch block be provided. ?

    Hello

    why do JDBC lines of code require a try/catch block be provided. ?

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: why do JDBC lines of code require a try/catch block be provided. ?

    Quote Originally Posted by vb_student
    Hello

    why do JDBC lines of code require a try/catch block be provided. ?
    a number of exceptions could be thrown. You may provide a bad password, bad db name, or the connection may fail due to some obscure reason. *Just because you want to establish a connection with a database doesn't mean it's going to happen.

  3. #3
    Lively Member
    Join Date
    Oct 2006
    Posts
    71

    Re: why do JDBC lines of code require a try/catch block be provided. ?

    It's been a while since I've done Java, but if I remember correctly, exceptions can be defined as checked or non-checked. A checked exception must either handle the exception, or throw it.

    So whoever wrote the JDBC methods thought it was a good idea to have those methods use checked exceptions.

    There's a lot of discussion on whether checked exceptions are a good idea or not. I'm not offering an opinion, but that's the way it is in Java.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width