• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

why the error at line 56 ?

 
Ranch Hand
Posts: 608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know why I keep getting error at line 56.

Hope someone can tell me why ?

Here's my code :

error-at-line-56.jpg
[Thumbnail for error-at-line-56.jpg]
 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your connection object is not creating. because you are creating the connection obj in catch block . so it will not get executed until try block will throw the exception . so change your code .

Create your con obj in try block
 
 
tangara goh
Ranch Hand
Posts: 608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

shiv darshan wrote:Your connection object is not creating. because you are creating the connection obj in catch block . so it will not get executed until try block will throw the exception . so change your code .

Create your con obj in try block
 





You mean I can't call the open Connection based on the above method ?
Why ?

It works for my other class ...

So, I have to move the method all together in the try catch block ?

Sorry I just don't understand...
 
shiv darshan
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Marshal
Posts: 69806
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done, SD, findingthe error, and welcome to the Ranch

Please use the code button; I shall edit your post and you can see how much better it will look
[edit]Also changed indentation for line 4.
 
Screaming fools! It's nothing more than a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic