Question: How to display all the Select values from the MySQL database table in where condition= In JSP?



Share on Google+Share on Google+

How to display all the Select values from the MySQL database table in where condition= In JSP?
1 Answer(s)      5 years and 9 months ago
Posted in : JavaScript Questions
**Hi in jsp,SQL select statement,i am unable to display all the select values from MySQL DB**
only first value is displayed in the jsp file.
@select * from table dept where dept_no=10;"

jsp code i have used is:
               <TD> <%= resultset.getString(1) %> </TD>
               <TD> <%= resultset.getString(2) %> </TD>  
it is displaying only the fist value that satisfied the condition,but i want all the rows to be displayed in the jsp file.
Plz help..thanks in advance.             
View Answers

July 29, 2011 at 3:39 PM

<%@ page import="java.sql.*" %>

<form method="post" name="form">
<table border="1">
<tr><th>DEPT NO</th><th>DEPT NAME</th></tr>
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from dept";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
catch(Exception e){


Related Tutorials/Questions & Answers:
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java


Advertisement null