Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy to retreive datas from mysql table in jsp

    Hi,
    I am trying to put a combo box using jsp and i want to retreive the datas from my sql table and display those inside combobox.I have tried the below code.but it displays nothing inside combobox.
    Code:
    <%@ page import="java.sql.*" %>
    <%@ page language="java" %>
    <html>
    <center>
    <table>
    <tr align=left><td>Location</td><td><SELECT NAME="location"   onChange="disp_text() ">
    <option value="">--- Select Location ----</option>
    <%
     
     
            try
     
             
     
             {
     
              
     
                  Class.forName
    ("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/conference", "meetme", "meetme");
    Statement st = conn.createStatement();
    ResultSet rs=st.executeQuery("select * from meetme");
    out.println("Values:" + rs.next());
    while(rs.next())
     
     
                  {
    <option value="<%=rs.getString("location")%>"><%= rs.getString("location") %> </option>
     
     
                  }
     
     
              }
     
     
      catch(Exception e)
     
      {
    e.printStackTrace(new PrintWriter(out));
    }%>
    </select></td></tr>
    </table>
    </center>
    </html>
    please help me to solve this.

    Thanks.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    does your table have any data? are you getting any error messages?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, i am having records in the table meetme which is in conference database.I am not getting any error message

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you shyam.my problem is solved.It is because of missing mysql jar file


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •