Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Db connection in jsp works but when bean used does not work[solved]  RSS feed

 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is directly embedded in the JSP page and it returns result properly....



Now, I use a bean to display rows in the Forum_tbl but it returns no result...why???

[ January 03, 2006: Message edited by: Raghavan Chockalingam ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've taken the time to put System.out.println statments in all of your catch blocks. Have you read the logs to see if there are any error messages?
If so, can you share them with us?
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found the errors
1. I have to move to the first record using result.first();
2. In the getName() method ...i forgot to make a call to getResults() method...
here is the modified program...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One observation that isn't really relevant to this question:

I don't see any code for insuring that the connection gets closed.
In a webapp, this is a recipe for memory leaks and errors caused by exausting the number of connections available.

A google search on JDBC tutorial should bring up plenty of good examples.
In all of them, you should see some kind of "finally" clause with code for closing the connection and releasing it's object variable.

Often these problems don't make themselves known until the product you're working on goes into production.
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben, I was busy with the connection and getting results for the past four hours so had not thought about closing connections but I will do as you said...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!