...

View Full Version : to retreive datas from mysql table in jsp



preethi A
04-10-2008, 10:29 AM
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.


<%@ 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.

shyam
04-10-2008, 10:53 AM
does your table have any data? are you getting any error messages?

preethi A
04-10-2008, 11:19 AM
yes, i am having records in the table meetme which is in conference database.I am not getting any error message

preethi A
04-11-2008, 06:27 AM
Thank you shyam.my problem is solved.It is because of missing mysql jar file



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum