Share on Google+Share on Google+

lokeshreddy
How to display all the rows in JSP ,MySQL select condition statement IN dept_table
1 Answer(s)      5 years and 9 months ago
Posted in : JavaScript Questions

I iam unable to display all the rows in JSP select statement from MYSQL DB.i have used the below code:only first row that satisfy the condition is displayed.@select * from department where dept_no=10;My display code in JSP is as follows.Plz help me to display all the rows that satisfy the condition.

Here is my code:

<TABLE BORDER="1">
            <TR>
               <TH>deptno</TH>
               <TH>deptname</TH>                                             
           </TR>
           <TR>
               <TD> <%= resultset.getString(1) %> </TD>
               <TD> <%= resultset.getString(2) %> </TD>               
           </TR>
       </TABLE>");

Thanks

Ads

View Answers

July 29, 2011 at 3:39 PM


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

<br><br>
<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;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from dept";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>









Related Tutorials/Questions & Answers:
How to display all the rows in JSP ,MySQL select condition statement IN dept_table
How to display all the rows in JSP ,MySQL select condition statement IN dept_table  I iam unable to display all the rows in JSP select statement from... is displayed.@select * from department where dept_no=10;My display code in JSP
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where condition= In JSP?  **Hi in jsp,SQL select statement,i am unable to display all the select values from MySQL DB** only first value is displayed
Advertisements
How to use select Statement in MySQL?
How to use select Statement in MySQL?  Hi, How to use select Statement in MySQL? I want to learn the various ways to use the SQL select statement... the select statement in MySQL Suppose we have following table: CREATE TABLE
return all rows mysql php
return all rows mysql php  How to find or return results that are not available in another table .. using join method in PHP and MYSql.   SELECT * FROM Declined LEFT JOIN Request ON Declined.RequestID
SQL select statement doesn't return any rows,
SQL select statement doesn't return any rows,  When an SQL select statement doesn't return any rows, is an SQLException thrown
mysql select statement - SQL
mysql select statement  i want to select id,name,age values from database.i created the following coding to select values from the table according to the id value which is selected by the user.pls help me select id,name,age from
MySQL Select Statement
statement in MySQL and you can also learn how to use SELECT statement with WHERE clause. The SELECT statement is used to retrieve the records from the table... MySQL Select Statement     
HOW TO DISPLAY 2 ROWS OF CONTROLS
HOW TO DISPLAY 2 ROWS OF CONTROLS  i can be display one row by selecting value from drop down box BUT ALSO i need to display 2 rows by selecting... = "<table id='table1'><tbody><tr><td><td><td><
PHP SQL Rows
; PHP SQL Rows is used to fetch the select the row value based on the condition... we create a table 'users'. The select query is used to returns  the records... of records  from table 'users' based on the condition specified in where Clause
how to select random rows from database through servlet
how to select random rows from database through servlet  hello i want to know, how to select random rows from database through servlet
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file..." in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP file,we have to retrieve the other fields from the dept table and display
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am not getting, how to do this by using this code. plz help me. if(rs1.next
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am not getting, how to do this by using this code. plz help me. if(rs1.next
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in image tag but i am not getting, how to do this by using this code. plz help me. if(rs1.next
Mysql Where Statement
Mysql Where Statement       Mysql Where Statement is useful when we want to return the records... The Tutorial illustrate an example from 'Mysql Where Statement'. To understand
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... at line: 113 in the jsp file: /Cat1.jsp The local variable v_RGPC may not have
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp project i have to show the photos in one cell depending on the selection from other...://www.roseindia.net/jsp/file_upload/ http://www.roseindia.net/jsp/file_upload
Mysql PHP Select
Mysql PHP Select       Mysql PHP is used to execute the select statement using mysql_query... table 'mytable' using select query. Now we make use of mysql_fetch_array
JDBC Select All Records Example
JDBC Select All Records Example In this tutorial we will learn how select all records from the table use mysql JDBC driver. This tutorial example  for select  all records from table if exist and defined how the records fetch
MySQL Nested Select Example
MySQL Nested Select Example       MySQL Nested Select is select query, that is nested inside the select, update and delete query  based on the condition specified in a Where
where clause in select statement
where clause in select statement  In Mysql,I write the following query: select * from emp where designation = "MANAGER" But the actual value in the table is "manager" Will the above query retrieve any records? According to me
Help with SELECT/JOIN statement
a select statement that will return me all rows of t1 but, when t1.id = t2.id, I...Help with SELECT/JOIN statement  I have two tables (t1 and t2... statement that will give me the result: id | name | value
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.   I have the same problem.plz help me. I have MySQL... have to display the Nodename and packageno. i.e.,select nodename,packageno from
Mysql Else Condition
Mysql Else Condition       Mysql Else Condition evaluate the statements in database to perform... illustrate an example from the 'Mysql Else Condition'.To understand
Mysql Cross Join Statement
crossjoin:- The below query return you all the records or rows from both table name... Mysql Cross Join Statement       Mysql Cross Join Statement is used to return the product
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
Retrieving All Rows from a Database Table
Retrieving All Rows from a Database Table       Here, you will learn how to retrieve all rows... string type parameter for executing the SQL statement. SELECT * FROM table_name
SQL SELECT DISTINCT Statement
or rows into table 'Stu_Table'. SQL statement to insert data into table...,'Santosh',10); Stu_Table The Select statement return you... with the Select statement to get all unique records from database
Deleting All Rows From the database Table
helps us to write on the browser. To delete all the rows from our database table... for deleting all the rows in the database table. This query will be fired... .style1 { margin-right: 0px; } Deleting All Rows
Tutorials   
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

Ads

 
Advertisement null

Ads