aspose file tools*
The moose likes JDBC and the fly likes get data from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "get data from database" Watch "get data from database" New topic
Author

get data from database

rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
I want to retrieve values from database to drop down box in servlet .I want database values in place of a and b.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Once you have retrieved the values from the DB you can use them however you like, including using them in a servlet. What do you have so far, and where are you stuck making progress?
rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
Tim Moores wrote:Once you have retrieved the values from the DB you can use them however you like, including using them in a servlet. What do you have so far, and where are you stuck making progress?


I am using this code but drop down box is empty.


Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The out.println statement looks completely messed up. It seems that you're printing a Java statement to the HTML output. I think you're missing some double quotes in there, and you shouldn't repeat the "out.println" part.

Also, you've checked that the ResultSet is not empty, yes?
rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
Tim Moores wrote:The out.println statement looks completely messed up. It seems that you're printing a Java statement to the HTML output. I think you're missing some double quotes in there, and you shouldn't repeat the "out.println" part.

Also, you've checked that the ResultSet is not empty, yes?


I have checked the resultset....it is not empty.
I am usingfollowing loop.
while(rs.next())
{
out.println(" <option value="+ rs.getString("NO")+" ></option>");

}
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
So it's working now?
rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
Tim Moores wrote:So it's working now?



yes it is working now..
 
jQuery in Action, 2nd edition
 
subject: get data from database