Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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
Marshal
Posts: 35279
384
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic