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 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

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
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
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
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 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
PHP SQL Rows
; PHP SQL Rows is used to fetch the select the row value based on the condition...'. To understand the example we create a table 'users'. The select query is used..._select_db("test", $con);   $result = mysql_query
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><
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
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
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
Mysql Where Statement
rows in set (0.00 sec) Query to display the record of table "... Mysql Where Statement       Mysql Where Statement is useful when we want to return the records
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
How to break statement in JSP
How to break statement in JSP  Hi, I am writing JSP page and there is for loop inside it. How to break statement in JSP? Thanks   Hi, I JSP you can use the break statement to break a loop. Here is simple example
How to break statement in JSP
How to break statement in JSP  Hi, I am writing JSP page and there is for loop inside it. How to break statement in JSP? Thanks   Hi, I JSP you can use the break statement to break a loop. Here is simple example
How to break statement in JSP
How to break statement in JSP  Hi, I am writing JSP page and there is for loop inside it. How to break statement in JSP? Thanks   Hi, I JSP you can use the break statement to break a loop. Here is simple example
How to break statement in JSP
How to break statement in JSP  Hi, I am writing JSP page and there is for loop inside it. How to break statement in JSP? Thanks   Hi, I JSP you can use the break statement to break a loop. Here is simple example
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 date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
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 PHP Select
; Mysql PHP is used to execute the select statement using mysql_query... rows in set (0.01 sec) Viewing table data using php select: To view the table..._num=mysql_num_rows($sql_result); echo "<table border=\"1\"
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 the data column on jsp
How to display the data column on jsp  My requirements: Display total... .. in table of each database having two columns: description, error. but data is dynamic. one database having 2 rows and another database could have 10 rows. so
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks   Hi, You should import...() %> Check complete tutorial at How to Create JSP Page? Thanks
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
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
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
how to display the email message in jsp
how to display the email message in jsp  hi every one .. i am new from this industry please help me to display the email message in jsp page please send me sample code
How to connect to MySQL in JSP?
How to connect to MySQL in JSP?  How to connect to MySQL in JSP..., You can use the Java JDBC code to connect to MySQL database in JSP page. Check the tutorial: Connect JSP with mysql Thanks
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
Mysql Else Condition
Mysql Else Condition       Mysql Else Condition evaluate the statements in database to perform..._TO_REPLACE_1 The Tutorial illustrate an example from the 'Mysql Else Condition
How to display multiple images in jsp
How to display multiple images in jsp  <%@ page import="java.io.... =Databasecon.getInstance(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select IMAGE from student_profile "); //ResultSet rs1=stmt.executeQuery
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
how to add the calendar to the dynamic rows in html or jsp page - JSP-Servlet
how to add the calendar to the dynamic rows in html or jsp page   Hi Sir, i have 3 columns in my jsp page date of payment,amount recieved,no and i have 2 button in my jsp page ADD and delete button. when i click on add
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file . look at the line with code-> Statement st=con.createStatement...; Statement st=null; try{ Class.forName("com.mysql.jdbc.Driver
Displaying Rows - JSP-Servlet
Displaying Rows  Hi, I need your support on how to display data from... servlet or jsp  Hi friend, This is form code, display data in servlet Display Data In Servlet
How to use 'if' statement in jsp page?
How to use 'if' statement in jsp page?  ... how to use 'if' statement in jsp page. This statement is used to test conditions. You can understand use of this statement by a real world example. Suppose
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
how to display jsp page containing mysql query in particular division using... will display here</div> </body> </html> print("code sample...">Your result will display here</div> </body> </html>
SQL SELECT DISTINCT Statement
The Insert into statement add the records or rows into table 'Stu_Table... Stu_Table The Select statement return you the records from... with the Select statement to get all unique records from database
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
Select from select list + display
Select from select list + display  i have a select list containing... select EmpCode from the select list, the corresponding EmpName and DeptName should...(":"); document.getElementById("name").value= strar[1]; document.getElementById("dept").value
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

Ads