aspose file tools*
The moose likes JDBC and the fly likes Get Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Get Database connection" Watch "Get Database connection" New topic
Author

Get Database connection

Dan Parsons
Ranch Hand

Joined: May 30, 2007
Posts: 70
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

...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

OCUP UML fundamental and ITIL foundation
youtube channel
Gavi jadz Grandea
Greenhorn

Joined: Sep 11, 2009
Posts: 17
I think what your trying to do is...

to get the connection.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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:




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Database connection