wood burning stoves 2.0*
The moose likes Servlets and the fly likes problem with Connection object in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with Connection object in a servlet" Watch "problem with Connection object in a servlet" New topic
Author

problem with Connection object in a servlet

Geetu Bahl
Greenhorn

Joined: Dec 01, 2004
Posts: 14
Hi

I need to retrieve data from oracle table. So i have established the conection in a class(pck1.dbcon)
Connection dbcon = DriverManager.getConnection("jdbc racle ci:@orcl", "scott", "tiger");

When i try to retrieve data from a servlet which imports this package, it gives error saying dbcon cannot be resolved.

Please Explain ?

Thanks
Geetu
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


So i have established the conection in a class(pck1.dbcon)
Connection dbcon = DriverManager.getConnection("jdbc racle ci:@orcl", "scott", "tiger");


You should have done this in a public (and static) method of the class.



ram.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Not a servlet question.

Edited:
Its a crosspost. Same thread.
[ April 14, 2005: Message edited by: Adeel Ansari ]
vasu devan
Ranch Hand

Joined: Apr 14, 2005
Posts: 38
Hi

I didnt used OCI for connecting Oracle databse,but the probelom may comes lots of conditions...(userid,driver probelom,etc..,)

But i might suggest one possiblity of accessing Oracle databse,by using oracle thin driver(this is pure type-4 driver).

Try this option

cheers
vasu
Geetu Bahl
Greenhorn

Joined: Dec 01, 2004
Posts: 14
thanks everyone, specially ram
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Originally posted by ramprasad madathil:


ram.

Hi Ram..
Do u think that after Class.forName(".....");
DriverManager,gerConcetion(".....");


Will work fine ...then y to do all these gossip in esply in public staic mtd..

Let me know if it is not OK for u.. or if u have any comments...

Thx and Regards
G R Ganesh Gowtham
grgowtham_cse@yahoo.com
Capricornsys inc, Hyderabad


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with Connection object in a servlet
 
Similar Threads
ServletContextListener
Applet doesn't establish JDBC connection
Problem with Jdbc connection object
DB2 connectivity - strange error
How to perform MultiTask in a Servlet