• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get Database connection

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the below data class that connects to Oracle without any issues in Tomcat 6.0.18. The web app is used about once or twice a week by 5 users.
Everytime I connect in a class I have to use the same setter and getter methods so I would like to put them in a seperate bean class and call it in each java class.
Here is what I have that currently works:



I tried putting it in a ConnBean java class like this:


New connection attempt keeps saying it cant find any connection info:


Please advise how I can make this work?
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TellTheDetails and I saw there is no constructor in ConnBean which takes the Connection as an input parameter
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...and I saw there is no constructor in ConnBean which takes the Connection as an input parameter...



Indeed. The code given by Dan does not compile.

Dan, please post the real code, and the real error messages.

Regards, Jan
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what your trying to do is...

to get the connection.
 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also get rid of the constructor and make the variables and methods static! Shift the getConnection() to the class City as a private method. So then you can just call them like:




 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic