<table bord" name="description">

search in Two Tables to Find data and view by jsp

Ads
 

search in Two Tables to Find data and view by jsp

hi i want search in Two Tables to Find data and view by jsp <%@page import="java.sql.*"%>

<table border="1">
<h2>Citizen account</h2>
<tr><td></td>

<td><b><u>Name</u></b></td>
<td><b><u>Account Number</u></b></td>
<td><b><u>Amount</u></b></td>
</tr>

<%
String acnumber =request.getParameter("acnumber");


try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
%>
<%
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/KDatabase","root","");
ResultSet rs = null;
Statement st=null;
%>
<%
st=conn.createStatement();
rs = st.executeQuery("select * from electricity where accountno='"+acnumber+"'");


if(rs=accountno){
int i=0; 
while(rs.next()){ 
%>

<tr>
<td> </td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("accountno") %></td>
<td><%= rs.getString("amount") %></td>


</tr><%
i++;
}

}else st=conn.createStatement();
rs = st.executeQuery("select * from electricity where accountno='"+acnumber+"'");
int i=0; 
while(rs.next()){ 
%>
<tr>
<td> </td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("accountno") %></td>
<td><%= rs.getString("amount") %></td>
</tr><%
i++;
}





}catch(SQLException e){ 

System.out.println(e.getMessage());
 } 

 %>

<jsp:include page="footcitilogin.jsp"/>
View Answers

February 22, 2012 at 4:52 PM

Have a look at the following link:

JSP search using two tables


February 22, 2012 at 9:04 PM

sorry my friend this is another issue, I want like

if found in first table print the row else go to second table.

rs = st.executeQuery("select * from electricity where accountno='"+acnumber+"'");
if(rs != null){              // If find it print("you paid")  If not go next step
out.println("you paid"+ rs);



}else if(rs == null) {      // here must print ("you must paying bill")
rs = st.executeQuery("select * from paying where accountno='"+acnumber+"'");
out.println(" you must pay  ");
}

February 23, 2012 at 7:25 AM

i want to write payment bill code (create two table the first table: the bills for user the admin insert in this table the second table: when the user pay insert in this table he has paid )

1-the user write account number and submit 2-the process search in the second table if he has paid give him message you have paid if not found it then search in the second table it must be there and view the bill for the user

Ads









Related Tutorials/Questions & Answers:
search in Two Tables to Find data and view by jsp
search in Two Tables to Find data and view by jsp  hi i want search in Two Tables to Find data and view by jsp <%@page import...; Have a look at the following link: JSP search using two tables   
How to send and view data in seperate tables of a swing application, to a japser reporting(two)
How to send and view data in seperate tables of a swing application, to a japser reporting(two)  I have 2 tables in one swing user interface. I want... want to know do for two tables. (here I am sending two parameters as well
Advertisements
How to send and view data in seperate tables of a swing application, to a japser reporting(two)
How to send and view data in seperate tables of a swing application, to a japser reporting(two)  I have 2 tables in one swing user interface. I want... want to know do for two tables. (here I am sending two parameters as well
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my...:8080/examples/jsp/1/insert.jsp"> <table> <tr><td>
Join the two tables in sql
Join the two tables in sql  How to join the two tables in SQL ..and return the value from common column in SQL Database
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
Joins tables in jsp
Joins tables in jsp       When we want to select data from two or more tables.... In this example we have two tables stu_info and stu_marks. Structure of these tables
View jsp
View jsp  <%@ page language="java" contentType="text/html; charset...; charset=ISO-8859-1"> <title>View ur Details</title> </head>...;%=request.getContextPath()%>/Controller"> <input type="hidden" name="page" value="view
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select...' in textbox and click on search button it should show me all the title names
add same tables in jsp page
add same tables in jsp page  hi I have a table in my jsp page with data, now I want to add same copy of table without its default value in same page whenever I click add more table, how do I do
SQL Server row comparison using two tables
SQL Server row comparison using two tables  insertion process are completed in table1.string comparison using table2 to table1 if any changes in these tables and then upadated
how to do two database tables in one page?
how to do two database tables in one page?  dear all: i want to show these two database tables in one page. one table on the left (dbtable.jsp..." value="Search"> </form> </html> ***dbtable.jsp
Search operation in JSP page
Search operation in JSP page  How to perform search in jsp with MYSQL database plz help me
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Combine Two Tables(Purchase and Sales) and getting Current Stock
Combine Two Tables(Purchase and Sales) and getting Current Stock  How can i combine both the Tables and Getting Current Stock
Lucene Search in JSP - JSP-Servlet
Lucene Search in JSP  Hello Sir, I want to Develop lucene - Search engine in Jsp page which can Search full text from XML file..through XML parser.. Example: in Search interface there are one textbox after putting some value
Search Page in jsp
Search Page in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
search form in jsp
search form in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
How to find out the friend user between two columns in sql database
How to find out the friend user between two columns in sql database  Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from
how to store array values into two different tables in java?
how to store array values into two different tables in java?  I have... and now I want to store these values in two different tables(i.e store 2 array values in one table and remaining two values in another table
find data science jobs
find data science jobs  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: find data... the topic "find data science jobs". Also tell me which is the good
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using
ModuleNotFoundError: No module named 'django-data-tables'
ModuleNotFoundError: No module named 'django-data-tables'  Hi, My... named 'django-data-tables' How to remove the ModuleNotFoundError: No module named 'django-data-tables' error? Thanks   Hi, In your
Purge Data from Mysql tables
Purge Data from Mysql tables  Hi, i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data. CREATE DEFINER=`root`@`localhost
Cross Join Tables in a Specific Database
join between two tables. The cross join operation retrieves data between two... and outer join operation. The cross join is used to retrieve data from tables... will be performed between two tables. Both tables hold some specific fields
ModuleNotFoundError: No module named 'data-view'
ModuleNotFoundError: No module named 'data-view'  Hi, My Python... 'data-view' How to remove the ModuleNotFoundError: No module named 'data... have to install padas library. You can install data-view python with following
ModuleNotFoundError: No module named 'data-view'
ModuleNotFoundError: No module named 'data-view'  Hi, My Python... 'data-view' How to remove the ModuleNotFoundError: No module named 'data... have to install padas library. You can install data-view python with following

Ads