About Java 3
class file :
1// FileAction.java
(Action) [ declare way sql and info(Model) file ]
2// InstitutesComputersSQL.java(Sql) [ Call 2sql query to
get value from 2table]
3// InstitutesComputersInfo (Model) [ Keep property For
2table ]
1///First
Action: ( FileAction.java )
N.B:
Here We will get value from 2 table As a single record file
InstitutesComputersInfo=institutesComputersSQL.showInstitutesComputers(institute_id);//k
ins pc
institutesComputersLibInfo=institutesComputersSQL.showInstitutesLibraries(institute_id);//k
ins lib
Here We have to set get
for this 2 variable (For single row variable)
1/ InstitutesComputersInfo
2/ institutesComputersLibInfo
So I have to add also below line:
InstitutesComputersSQL
institutesComputersSQL=new InstitutesComputersSQL();//k pc
So I have to add also below line: Declare Way ( Single Row and
Multiple Row as Private or not)
Single Row:
private InstitutesComputersInfo
InstitutesComputersInfo=new InstitutesComputersInfo();//k pc
private InstitutesComputersInfo
institutesComputersLibInfo=new InstitutesComputersInfo();//k pc as Private or
not
Or
InstitutesComputersInfo
InstitutesComputersInfo=new InstitutesComputersInfo();//k pc
InstitutesComputersInfo
institutesComputersLibInfo=new InstitutesComputersInfo();//k pc libraries
n.b: as single row , so not
list and array use Like list
2///Second
Sql ( InstitutesComputersSQL.java )
Get value
from 2 table :
package SQLQuery.Patient;
import
java.sql.Connection;
import
java.sql.ResultSet;
import
java.sql.SQLException;
import
java.sql.Statement;
import
Database.DatabaseConnection;
import
com.allClass.Model.InstitutesComputersInfo;
public class
InstitutesComputersSQL {
private Connection con=null;
private Statement st=null;
private ResultSet rs=null;
DatabaseConnection
dbc=new
DatabaseConnection();
// START
2 QUERY
// SINGLE ROW RETURN QUERY INSTITUTES
COMPUTERS
public
InstitutesComputersInfo showInstitutesComputers(String institute_id){ //Kaniz
String
sql ="";
boolean fg = true;
InstitutesComputersInfo
institutesComputersInfo = new InstitutesComputersInfo();
con = dbc.connectDB();
if (con == null) {
fg
= false;
}
if (fg) {
try {
st = con.createStatement();
//sql
="select i.eiin,i.division_id,(select division_name from lookup_divisions
where division_id=i.division_id) as division_name from institutes i where
institute_id = '"+institute_id+"'";
sql ="select
computer_yn,computer_working,computer_notworking,dsktop_int,laptop_int,moe,ngo,bcc,bought,dshe,other,board,computer_teaching_yn,comp_teacher_yn,comp_teacher_qual,comp_training_type,electricity_yn,solar_panel_yn,solar_fan,solar_light,internet_conn_yn,multimedia_yn,no_multimedia
from institutes_computers i where institute_id = '"+institute_id+"'";
System.out.println("sql
:" + sql);
rs = st.executeQuery(sql);
while (rs.next()) {
institutesComputersInfo.setComputer_yn(rs.getString("computer_yn"));
institutesComputersInfo.setComputer_working(rs.getString("computer_working"));
institutesComputersInfo.setComputer_notworking(rs.getString("computer_notworking"));
institutesComputersInfo.setDsktop_int(rs.getString("dsktop_int"));
institutesComputersInfo.setLaptop_int(rs.getString("laptop_int"));
institutesComputersInfo.setMoe(rs.getString("moe"));
institutesComputersInfo.setNgo(rs.getString("ngo"));
institutesComputersInfo.setBcc(rs.getString("bcc"));
institutesComputersInfo.setBought(rs.getString("bought"));
institutesComputersInfo.setDshe(rs.getString("dshe"));
institutesComputersInfo.setOther(rs.getString("other"));
institutesComputersInfo.setBoard(rs.getString("board"));
institutesComputersInfo.setComputer_teaching_yn(rs.getString("computer_teaching_yn"));
institutesComputersInfo.setComp_teacher_yn(rs.getString("comp_teacher_yn"));
institutesComputersInfo.setComp_teacher_qual(rs.getString("comp_teacher_qual"));
institutesComputersInfo.setComp_training_type(rs.getString("comp_training_type"));
institutesComputersInfo.setElectricity_yn(rs.getString("electricity_yn"));
institutesComputersInfo.setSolar_panel_yn(rs.getString("solar_panel_yn"));
institutesComputersInfo.setSolar_fan(rs.getString("solar_fan"));
institutesComputersInfo.setSolar_light(rs.getString("solar_light"));
institutesComputersInfo.setInternet_conn_yn(rs.getString("internet_conn_yn"));
institutesComputersInfo.setMultimedia_yn(rs.getString("multimedia_yn"));
institutesComputersInfo.setNo_multimedia(rs.getString("no_multimedia"));
}
}
catch (SQLException
sq) {
sq.printStackTrace();
}
finally {
try {
if (rs != null) {
rs.close();
}
con.close();
}
catch (SQLException
ex) {
ex.printStackTrace();
}
}
}
return
institutesComputersInfo;
}
// SINGLE ROW RETURN QUERY INSTITUTES
LIBRARIES
public InstitutesComputersInfo
showInstitutesLibraries(String institute_id){ //single Row Return
String
sql ="";
boolean fg = true;
InstitutesComputersInfo
institutesComputersInfo = new InstitutesComputersInfo();
con = dbc.connectDB();
if (con == null) {
fg
= false;
}
if (fg) {
try {
st = con.createStatement();
sql ="select
sperate_room_yn,seperate_building_yn,no_book,book_issue_yn,regular_issue_yn,librarian_teacher_yn,training_yn
from institutes_libraries i where institute_id = '"+institute_id+"'";
System.out.println("sql
:" + sql);
rs = st.executeQuery(sql);
while (rs.next()) {
institutesComputersInfo.setSperate_room_yn(rs.getString("sperate_room_yn"));
institutesComputersInfo.setSeperate_building_yn(rs.getString("seperate_building_yn"));
institutesComputersInfo.setNo_book(rs.getString("no_book"));
institutesComputersInfo.setBook_issue_yn(rs.getString("book_issue_yn"));
institutesComputersInfo.setRegular_issue_yn(rs.getString("regular_issue_yn"));
institutesComputersInfo.setLibrarian_teacher_yn(rs.getString("librarian_teacher_yn"));
institutesComputersInfo.setTraining_yn(rs.getString("training_yn"));
}
}
catch (SQLException
sq) {
sq.printStackTrace();
}
finally {
try {
if (rs != null) {
rs.close();
}
con.close();
}
catch (SQLException
ex) {
ex.printStackTrace();
}
}
}
return institutesComputersInfo;
}
// END 2 QUERY
}
3///
Third table property [InstitutesComputersInfo.java]
Property Set
in info file:
package
com.allClass.Model;
public class InstitutesComputersInfo {
// Here
declare table coloumn name 21. Table
name is institutes_computers
String
computer_yn;
String
computer_working;
String
computer_notworking;
String
dsktop_int;
String
laptop_int;
String
moe;
String
ngo;
String
bcc;
String
bought;
String
dshe;
String
other;
String
board;
String
computer_teaching_yn;
String
comp_teacher_yn;
String
comp_teacher_qual;
String
comp_training_type;
String
electricity_yn;
String
solar_panel_yn;
String
solar_fan;
String
solar_light;
String
internet_conn_yn;
// Here
declare table coloumn name 9. Table name
is institutes_computers
String
multimedia_yn;
String
no_multimedia;
String
sperate_room_yn;
String
seperate_building_yn;
String
no_book;
String
book_issue_yn;
String
regular_issue_yn;
String
librarian_teacher_yn;
String
training_yn;
public String
getComputer_yn() {
return computer_yn;
}
public void
setComputer_yn(String computer_yn) {
this.computer_yn = computer_yn;
}
public String
getComputer_working() {
return computer_working;
}
public void
setComputer_working(String computer_working) {
this.computer_working = computer_working;
}
public String
getComputer_notworking() {
return computer_notworking;
}
public void setComputer_notworking(String
computer_notworking) {
this.computer_notworking =
computer_notworking;
}
public String
getDsktop_int() {
return dsktop_int;
}
public void
setDsktop_int(String dsktop_int) {
this.dsktop_int = dsktop_int;
}
public String
getLaptop_int() {
return laptop_int;
}
public void
setLaptop_int(String laptop_int) {
this.laptop_int = laptop_int;
}
public String getMoe()
{
return moe;
}
public void setMoe(String
moe) {
this.moe = moe;
}
public String getNgo()
{
return ngo;
}
public void setNgo(String
ngo) {
this.ngo = ngo;
}
public String getBcc()
{
return bcc;
}
public void setBcc(String
bcc) {
this.bcc = bcc;
}
public String
getBought() {
return bought;
}
public void
setBought(String bought) {
this.bought = bought;
}
public String
getDshe() {
return dshe;
}
public void setDshe(String
dshe) {
this.dshe = dshe;
}
public String
getOther() {
return other;
}
public void setOther(String
other) {
this.other = other;
}
public String
getBoard() {
return board;
}
public void setBoard(String
board) {
this.board = board;
}
public String
getComputer_teaching_yn() {
return computer_teaching_yn;
}
public void
setComputer_teaching_yn(String computer_teaching_yn) {
this.computer_teaching_yn =
computer_teaching_yn;
}
public String
getComp_teacher_yn() {
return comp_teacher_yn;
}
public void setComp_teacher_yn(String
comp_teacher_yn) {
this.comp_teacher_yn =
comp_teacher_yn;
}
public String
getComp_teacher_qual() {
return comp_teacher_qual;
}
public void
setComp_teacher_qual(String comp_teacher_qual) {
this.comp_teacher_qual = comp_teacher_qual;
}
public String
getComp_training_type() {
return comp_training_type;
}
public void
setComp_training_type(String comp_training_type) {
this.comp_training_type =
comp_training_type;
}
public String
getElectricity_yn() {
return electricity_yn;
}
public void
setElectricity_yn(String electricity_yn) {
this.electricity_yn =
electricity_yn;
}
public String
getSolar_panel_yn() {
return solar_panel_yn;
}
public void
setSolar_panel_yn(String solar_panel_yn) {
this.solar_panel_yn =
solar_panel_yn;
}
public String
getSolar_fan() {
return solar_fan;
}
public void
setSolar_fan(String solar_fan) {
this.solar_fan = solar_fan;
}
public String
getSolar_light() {
return solar_light;
}
public void setSolar_light(String
solar_light) {
this.solar_light = solar_light;
}
public String
getInternet_conn_yn() {
return internet_conn_yn;
}
public void
setInternet_conn_yn(String internet_conn_yn) {
this.internet_conn_yn =
internet_conn_yn;
}
public String getMultimedia_yn()
{
return multimedia_yn;
}
public void
setMultimedia_yn(String multimedia_yn) {
this.multimedia_yn =
multimedia_yn;
}
public String
getNo_multimedia() {
return no_multimedia;
}
public void
setNo_multimedia(String no_multimedia) {
this.no_multimedia =
no_multimedia;
}
public String
getSperate_room_yn() {
return sperate_room_yn;
}
public void
setSperate_room_yn(String sperate_room_yn) {
this.sperate_room_yn =
sperate_room_yn;
}
public String getSeperate_building_yn()
{
return seperate_building_yn;
}
public void
setSeperate_building_yn(String seperate_building_yn) {
this.seperate_building_yn =
seperate_building_yn;
}
public String
getNo_book() {
return no_book;
}
public void setNo_book(String
no_book) {
this.no_book = no_book;
}
public String
getBook_issue_yn() {
return book_issue_yn;
}
public void
setBook_issue_yn(String book_issue_yn) {
this.book_issue_yn =
book_issue_yn;
}
public String
getRegular_issue_yn() {
return regular_issue_yn;
}
public void
setRegular_issue_yn(String regular_issue_yn) {
this.regular_issue_yn =
regular_issue_yn;
}
public String
getLibrarian_teacher_yn() {
return librarian_teacher_yn;
}
public void
setLibrarian_teacher_yn(String librarian_teacher_yn) {
this.librarian_teacher_yn =
librarian_teacher_yn;
}
public String
getTraining_yn() {
return training_yn;
}
public void
setTraining_yn(String training_yn) {
this.training_yn = training_yn;
}
}