Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet how to get data from database into dropdownlist in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Amyn Kapadia
how to get data from database into dropdownlist in jsp
3 Answer(s)      a year and 8 months ago
Posted in : JSP-Servlet


Can anybody tell me what is the problem in this code as i am not able to fetch the data from the database and set it into dropdown list in jsp please help

<br/>Customer Name:<select name="name">
     <% 
     try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/scs","root","root");
        Statement st=con.createStatement();
        String sql="select * from staff";
        ResultSet rs=st.executeQuery(sql);
        while(rs.next()){
         //String name = rs.getString("name");
     }
   %>
   <option value="<%=rs.getString("fname")%>"></option>

     <%
        }catch(Exception e){
        }     
     %>

 </select>

Advertisement
View Answers

February 6, 2013 at 1:41 PM


hi friend,

I think you did all the steps right but you missed to place the value of resultset between the <option></option> tag.

while(rs.next())
        {
            String name = rs.getString("name");         
        %>
        <option value="<%=name %>"><%=name %></option>
        <%
        }

For detail tutorial go through the link JSP Get Data Into Dropdown list From Database



February 6, 2013 at 5:07 PM


Thanq for reply but sorry i cant understand wht u r trying to say......

<option value="<%=rs.getString("fname")%>"></option>

i hv writn the value in the



August 20, 2013 at 2:19 PM


you are placing only the value not text between



Related Tutorials/Questions & Answers:
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  //Customer Name: <select name="name"> <% try{ Class.forName...="select * from staff"; ResultSet rs=st.executeQuery(sql); while(rs.next
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Customer Name:<select name="name"> <% try{ Class.forName...=con.createStatement(); String sql="select * from staff"; ResultSet rs
Advertisements
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Can anybody tell me what is the problem in this code as i am not able to fetch the data from... tutorial go through the link JSP Get Data Into Dropdown list From Database   
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   </script> </head> <body> <select name... * from countryname"); while(rs.next()){ %> <option value="<
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select an entry suppose 'title' from dropdownlist and give a title name 'partial dif
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
dynamic retrival of data from mysql database to dropdownlist in jsp
dynamic retrival of data from mysql database to dropdownlist in jsp  Hello, Am having problem in my project... i want to retrive the data from mysql database to the dropdownlist in jsp. Example: 1st i want to display the list
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... in the sense to get data from the database like oracle . I have created one jsp
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... example which lets you understand to fetch data from database in JSP
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
how to get data from checkboxes - JSP-Servlet
how to get data from checkboxes  hi, i got list of tables on screen... need to get only those tables to the next page where i can get list of columns to that selected tables. please help me.  hi, we can get the selected
How to get the most recent data from the sql database
How to get the most recent data from the sql database  Hi, just wanted to show the most recent row from the database table...in my web page. for example if i have four records in the table that was added on different different
how to get the data from database - Java Server Faces Questions
how to get the data from database  In database i have created some tables(person details) and i have one jsf page in that one search button... me the procedure how to do this application.Database is mysql.  Hi
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
How save,get picture from database in my jsp page?
How save,get picture from database in my jsp page?  How i save picture in db after browsing it,and also how i get it on my other jsp page
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database...(); in the below example. the error is "cannot convert from java.sql.Statement
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf  Hi, 1.how to get the data from database. 2.how to display the database...; Hi friend, To Solve the Problem get the data from database
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records
JSP Get Data Into Dropdown list From Database
JSP Get Data Into Dropdown list From Database In this section we will discuss.... This tutorial explains you that how to fetch data from database and set... data from the database and set it into the dropdown list in JSP using MySQL
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I...: From: Matter : Status... ,matter,file field values but not status and from field i am getting null
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put... deleted from jsp page as well as from database.I used mysql and jsp. Please help me
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
How to add value from sql server in dropdownlist
How to add value from sql server in dropdownlist  I have created a hospital management project using jsp servlet, where one form name is patient... id from other table like out patient, and this id will be stored dynamically
 

 

 

DMCA.com