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

Setting the attribute

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
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...


Cheers,
Richard
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

1. you get any exception?

2.whether your while loop getting executed?

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 06, 2008
Posts: 116
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 06, 2008
Posts: 116
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 06, 2008
Posts: 116
Thank You Very Much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting the attribute