• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Database connection

 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TellTheDetails and I saw there is no constructor in ConnBean which takes the Connection as an input parameter
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
 
Gavi jadz Grandea
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what your trying to do is...

to get the connection.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • 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:




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic