• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Setting the attribute

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am fetching the value from the database which is done in a servlet. There are two columns in this employee table with only one row data in it.

****************************************************************
When i try to display the attributes using the getAttribute, the values are not getting populated.
ie. The attribute "employee" is assigned with the blank space not with the value returned from the sql query.
IS there anything wrong in setting the attribute. Please help. Many thanks...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

1. you get any exception?

2.whether your while loop getting executed?

 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Actually i have missed one statement for loading the driver.

1) No.I am not getting any exception.
2) Yes. you are right. While loop is not getting executed. The flow stops after this line "String password = "rich"; Its getting stopped when trying to load the driver and getting connection. But can you please tell me where can i find any exception details, if at all there is any problem with the establishing connection,
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by renu richard:
Actually i have missed one statement for loading the driver.



Then, you should get Exception. in catch block your just printing the error message. i suggest you to use e.printStackTrace()

how you are running the program? you can see exception in the output console
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just giving the URL in the browser, and when i hit it, it will call the corresponding JSP. I am not using IDE"s like Eclipse. can you tell me where will i find the Stacktrace.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by renu richard:
I am just giving the URL in the browser, and when i hit it, it will call the corresponding JSP. I am not using IDE"s like Eclipse. can you tell me where will i find the Stacktrace.



which server you are using? you can see the exception in server console.

i guess you are using tomcat and starting the tomcat using window installer. right? if yes, use startup.bat to start the tomcat for that you need to set JAVA_HOME and CATALINA_HOME.

Hope This Helps
[ October 30, 2008: Message edited by: seetharaman venkatasamy ]
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for that. This is the exception that i am getting.
Exception is : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
Could not connect to DB: No suitable driver
---------------------------------------------------------
But i dont understand that when i run a simple java program that connects to database,i am able to connect. But when i try it from servlet using Tomcat, i can't. Can you please tell me, do i need to configure any other driver details for Tomcat?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by renu richard:

But i dont understand that when i run a simple java program that connects to database,i am able to connect. But when i try it from servlet using Tomcat, i can't.



you need to put driver jar(you are using Oracle driver) file under the tomcat/common/lib folder
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Very Much
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic