how to retrieve data from multiple tables in jsp using javabeans

how to retrieve data from multiple tables in jsp using javabeans

hey friends....

plz me to solve this question...

I have used the following code 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???

1)first -.java file

package pack;

public class admin {

private int Book_id;


private String name;

public int getBook_id() {
    return Book_id;
}

public void setBook_id(int Book_id) {
    this.Book_id = Book_id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getPh_no() {
    return ph_no;
}

public void setPh_no(int ph_no) {
    this.ph_no = ph_no;
}
private int ph_no;

}

2). .java file

package pack; import java.sql.*;

import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger;

public class admindao { Connection con; public admindao(){ try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ips?user=root&password=mysql"); } catch (SQLException ex) { Logger.getLogger(admindao.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(admindao.class.getName()).log(Level.SEVERE, null, ex); }

} public ArrayList getadmin() { ArrayList list = new ArrayList();

    try {

        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("select B.book_id,B.name,B.phoneno   from booking_table B");
        while (rs.next()) {
            admin u1 = new admin();
            u1.setBook_id(rs.getInt(1));
            u1.setName(rs.getString(2));
            u1.setPh_no(rs.getInt(3));
           // u1.setSeat_no(rs.getInt(2));
            list.add(u1);
        }

    } catch (SQLException ex) {
        Logger.getLogger(admindao.class.getName()).log(Level.SEVERE, null, ex);
    }


  return list;

} }

3).second .java file for getting data from second table-

package pack;

public class table2 { private int seat_no;

public int getSeat_no() {
    return seat_no;
}

public void setSeat_no(int seat_no) {
    this.seat_no = seat_no;
}

} 4)..java for second table_

package pack; import java.sql.*; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger;

public class table2dao{ Connection con1; public table2dao(){ try { Class.forName("com.mysql.jdbc.Driver"); con1 = DriverManager.getConnection("jdbc:mysql://localhost:3306/ips?user=root&password=mysql"); } catch (SQLException ex) { Logger.getLogger(table2dao.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(table2dao.class.getName()).log(Level.SEVERE, null, ex); }

} public ArrayList gettable2 (){ ArrayList list1 = new ArrayList();

    try {

        Statement stmt = con1.createStatement();
        ResultSet rs1 = stmt.executeQuery("select seat_id from booked_table ");

        while (rs1.next()) {
            table2 u1 = new table2();
            u1.setSeat_no(rs1.getInt(2));


            list1.add(u1);
        }

    } catch (SQLException ex) {
        Logger.getLogger(table2dao.class.getName()).log(Level.SEVERE, null, ex);
    }


  return list1;

} }

5)..jsp file-

<%@page import="java.util.*"%> <%@page import="java.util.ArrayList"%> <%@page import="pack.*"%> <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> Untitled Document

<% admindao ud=new admindao(); ArrayListlist=ud.getadmin(); %> <% table2dao tb=new table2dao(); ArrayListlist1=tb.gettable2(); %> <%for(admin a:list) { %> <%} %> <%for(table2 t:list1) { %> <%} %>
book_id <%=a.getBook_id()%>
name <%=a.getName()%>
phone no <%=a.getPh_no()%>
seat_no <%=t.getSeat_no()%>

View Answers









Related Tutorials/Questions & Answers:
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...).second .java file for getting data from second table- package pack; public
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...).second .java file for getting data from second table- package pack; public
Advertisements
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...).second .java file for getting data from second table- package pack; public
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where...=request.getParameter("username"); String sql; sql="SELECT * FROM register WHERE
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
Data fetch from multiple SQL tables - Hibernate
multiple tables using left and right outer joins. I need to convert this JDBC data... that would use table classes to retrieve data from 8 or 9 tables. Any example of HQL fetching data from multiple tables would be a help. I have tried
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box...... i already stored combo box values from database. pl
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me... the following link: http://www.roseindia.net/jsp/comboSelect.shtml Hope
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends... related value.... I am using only this page.. not get value from another page... in combo box from database.. by using select*from studentinformation; But when i
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Selecting particular data from multiple tables at database and perfoming calculations
Selecting particular data from multiple tables at database and perfoming... users for 1 year and update the details in jsp page.. so i have decided... the output based on month) .. I have created 12 tables with table name
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
Retrieve data from xml using servlets
Retrieve data from xml using servlets  Hi plz send me the code for retrieving the data from xml File using Servlets.   Hi, Do you want... File using ServletADS_TO_REPLACE_2 Thanks   Hi, Learn Get Data From
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few... using java servlet from the database in the jsp page
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
How to get data from Oracle database using JSP
the answer to retrieve data from the database by using servlet or jsp program...How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have
how to use bean to retrieve data from database
how to use bean to retrieve data from database  how to use bean to retrieve data from database   poda sendru
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi..... i ve... that data will b stored in db(m using sybase). 2.also hw to retrieve the data from.../javascriptpagerefresh.shtml http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
How to carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using the below code I am able to carry the username to a JSP (single value... needs to be carried from my servlet to a JSP. How do I do
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
How to Retrieve data from database in jsp
How to Retrieve data from database in jsp In this section we will discuss about how to fetch data from database table. We will give a simple example which... Here is the video tutorial of "How to retrieve data from database
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I am total new to JSP although I am learning it for the last few days. Now I want to use MySQL Database from JSP page. How to retrieve image from database using
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi, i have created... will b stored in db(m using sybase). 2.also hw to retrieve the data from db. cn u...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3
How to pass multiple values from a servlet to JSP?
How to pass multiple values from a servlet to JSP?  hi, I want to pass multiple values form a servlet to JSP. Hw do i do that? I am able to send one value at a time without any prb, but I am unable to carry multiple (from two
how to retrieve images from database to jsp?
how to retrieve images from database to jsp?  Hi sir,i want to stores...=con.createStatement(); String strQuery = "select * from data"; ResultSet rs...(); String strQuery = "select image from data where id="+id; ResultSet rs
how to retrieve blob data - JSP-Servlet
how to retrieve blob data  How to retrieve the BLOB table having single row single column in Database containing memory information using JSP...://www.roseindia.net/jsp/retrieve-image.shtml Thanks

Ads