• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Jdbc connection object

 
Geetu Bahl
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have established JDBC connection in a class named as Dbcon in package conn.

Connection dbcon = DriverManager.getConnection("jdbc racle : oci : @orcl", "username", "password")

Now i import this package in a servlet and try to use dbcon but it gives an error saying dbcon can not be resolved.

Kindly tell how to correct this

Thanks
Geetu
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36027
431
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Geetu,
dbConn is a local variable. It goes out of scope at the end of the block/method it is defined in. Try moving this code to the place where you actually use dbConn.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!