How to display all the rows in JSP ,MySQL select condition statement IN dept_table

Ads

 
 

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)      6 years and 2 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 [email protected] * 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>

Ads









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 [email protected]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
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     
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
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 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><
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
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 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 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
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
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 display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
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
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
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
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
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
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
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
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
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(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
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
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

 
Advertisement null

Ads