Professional Documents
Culture Documents
//Import Package:
import java.sql.*;
import javax.swing.JOptionPane;
try
{
Class.forName("java.sql.Driver");
Page 1 of 43
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement st=(Statement)con.createStatement();
String q="Select * from signup";
ResultSet rs=st.executeQuery(q);
while(rs.next())
{
String us=rs.getString("usernm");
String password=rs.getString("pass");
if((user.equals(us))&&(pwd.equals(password)))
{
new I4().setVisible(true);
this.setVisible(false);
}
}
con.close();
st.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}
Page 2 of 43
Create New Account Window
//Import Package:
import java.sql.*;
import javax.swing.JOptionPane;
Page 4 of 43
Sign In Window
//Import Package:
import java.sql.*;
import javax.swing.JOptionPane;
try
{
Class.forName("java.sql.Driver");
Page 5 of 43
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement st=(Statement)con.createStatement();
String q="Select * from signup";
ResultSet rs=st.executeQuery(q);
while(rs.next())
{String us=rs.getString("usernm");
String password=rs.getString("pass");
if((user.equals(us))&&(pwd.equals(password)))
{
new I4().setVisible(true);
this.setVisible(false);
}
}
con.close();
st.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}
Page 6 of 43
Information Window
Page 7 of 43
Procedure Window
new I6().setVisible(true);
this.setVisible(false);
Page 8 of 43
Order Window
//Import Package:
import java.sql.*;
import javax.swing.table.DefaultTableModel;
Page 10 of 43
cbook=" I Am America(And So Can You!) Stephen Colbert";
else if(com.getSelectedIndex()==20)
cbook=" The Matian Andy Weir";
else if(com.getSelectedIndex()==21)
cbook=" Running With Scissors Augusten Buroughs";
else if(com.getSelectedIndex()==22)
cbook=" Food : A Love story jim Gaffigan";
else if(com.getSelectedIndex()==23)
cbook=" Lucky Jim Kingsley Amis";
else if(com.getSelectedIndex()==24)
cbook=" How to Be a Woman Caitlin Morna";
else if(com.getSelectedIndex()==25)
cbook=" Insane City Dave Barry";
else if(com.getSelectedIndex()==26)
cbook=" Good Omens Terry Pratcheet";
else if(com.getSelectedIndex()==27)
cbook="Me & Earl & the Dying Girl Jesse Andrew";
else if(com.getSelectedIndex()==28)
cbook=" Seriously.....I'm Kidding Ellen De Geners";
else if(com.getSelectedIndex()==29)
cbook=" Not That Kind of girl Lena Dunhan";
Page 11 of 43
//Coding for Show:
DefaultTableModel model=(DefaultTableModel)tab1.getModel();
int rows=model.getRowCount();
if(rows>0) {
for(int i=0;i<rows;i++) {
model.removeRow(0);
}
}
String query="Select title,author,book_id from books where genre='comedy'";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next()) {
String btitle=rs.getString("title");
String bauthor=rs.getString("author");
String bbook_id=rs.getString("book_id");
//System.out.println(btitle+"/"+bauthor+"/"+bbook_id);
model.addRow(new Object[]{btitle,bauthor,bbook_id});
}
} catch(Exception e) {
JoptionPane.showMessageDialog(this, e.getMessage());
}
Page 12 of 43
//Coding for Next:
new I7().setVisible(true);
this.setVisible(false);
Page 13 of 43
Order Window
//Import Package:
import java.sql.*;
import javax.swing.table.DefaultTableModel;
Page 14 of 43
hbook="The Exorcist William Peter Blatty";
else if(ho.getSelectedIndex()==3)
hbook="Ghost Story Peter Straub";
else if(ho.getSelectedIndex()==4)
hbook="American Psycho Bret Easton Ellis";
else if(ho.getSelectedIndex()==5)
hbook="Hell House Richard Matheson";
else if(ho.getSelectedIndex()==6)
hbook="Dracula Bram Stoker ";
else if(ho.getSelectedIndex()==7)
hbook=" The Handmaid's Tale Margaret Atwood";
else if(ho.getSelectedIndex()==8)
hbook="The Best of H.P. Lovecraft H.P. Lovecraft ";
else if(ho.getSelectedIndex()==9)
hbook="The Best of H.P. Lovecraft2 H.P. Lovecraft ";
else if(ho.getSelectedIndex()==10)
hbook="The Turn of the Screw Henry James ";
else if(ho.getSelectedIndex()==11)
hbook="House of leaves Mark Z.Danielewski ";
else if(ho.getSelectedIndex()==12)
hbook="The Haunting of Hill House Shirley Jackson ";
else if(ho.getSelectedIndex()==13)
hbook=" The Silence of the lambs Ira Levin";
else if(ho.getSelectedIndex()==14)
hbook=" The Silence of the lambs2 Ira Levin";
else if(ho.getSelectedIndex()==15)
hbook=" The Amityville Horror Jay Anson";
else if(ho.getSelectedIndex()==16)
hbook=" The Trial Franz Kafka";
else if(ho.getSelectedIndex()==17)
Page 15 of 43
hbook="Blood Meridian Cormac McCarthy ";
else if(ho.getSelectedIndex()==18)
hbook="Book of Blod Clive Barker ";
else if(ho.getSelectedIndex()==19)
hbook="Heart-Shaped Box Joe Hill ";
else if(ho.getSelectedIndex()==20)
hbook=" Carrion Comfort Dan Simmons ";
else if(ho.getSelectedIndex()==21)
hbook="The Complete Tales and Poems Edgar Allan Pe ";
Page 16 of 43
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement stmt=(Statement)con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String btitle=rs.getString("title");
String bauthor=rs.getString("author");
String bbook_id=rs.getString("book_id");
//System.out.println(btitle+"/"+bauthor+"/"+bbook_id);
model.addRow(new Object[]{btitle,bauthor,bbook_id});
}
}
catch(Exception e)
{
JoptionPane.showMessageDialog(this, e.getMessage());
}
new I8().setVisible(true);
this.setVisible(false);
new I6().setVisible(true);
this.setVisible(false);
Page 17 of 43
Order Window
//Import Package:
import java.sql.*;
import javax.swing.table.DefaultTableModel;
Page 19 of 43
kbook="Frog and Toad Are Friends Arnold Lobel ";
else if(kido.getSelectedIndex()==18)
kbook="George and Martha James Marshall ";
else if(kido.getSelectedIndex()==19)
kbook="Go, Dog. Go! P.D. Eastman ";
else if(kido.getSelectedIndex()==20)
kbook="Grandfather’s Journey Allen Say ";
else if(kido.getSelectedIndex()==21)
kbook="Green Eggs and Ham Dr. Seuss ";
else if(kido.getSelectedIndex()==22)
kbook="Hatchet Gary Paulsen ";
else if(kido.getSelectedIndex()==23)
kbook="Holes Louis Sachar ";
else if(kido.getSelectedIndex()==24)
kbook="The Invention of Hugo Cabret Brian Selznick ";
else if(kido.getSelectedIndex()==25)
kbook="Jumanji Chris Van Allsburg ";
else if(kido.getSelectedIndex()==26)
kbook="The Lion and the Mouse Jerry Pinkney ";
else if(kido.getSelectedIndex()==27)
kbook="The Little Prince Antoine de Saint-Exupéry ";
else if(kido.getSelectedIndex()==28)
kbook="Madeline Ludwig Bemelmans ";
else if(kido.getSelectedIndex()==29)
kbook="Matilda Roald Dahl ";
else if(kido.getSelectedIndex()==30)
kbook="My Father’s Dragon Ruth Stiles Gannett ";
else if(kido.getSelectedIndex()==31)
kbook="My Name is Yoon Helen Recorvits ";
else if(kido.getSelectedIndex()==32)
Page 20 of 43
kbook="One Crazy Summer Rita Williams-Garcia ";
else if(kido.getSelectedIndex()==33)
kbook="Pink and Say Patricia Polacco ";
else if(kido.getSelectedIndex()==34)
kbook="Rickshaw Girl Mitali Perkins ";
else if(kido.getSelectedIndex()==35)
kbook="Rumpelstiltskin Paul O. Zelinsky ";
else if(kido.getSelectedIndex()==36)
kbook="The Snowy Day Ezra Jack Keats ";
else if(kido.getSelectedIndex()==37)
kbook="The Story of Ferdinand Munro Leaf ";
Page 21 of 43
//Coding for Show:
DefaultTableModel model=(DefaultTableModel)tab3.getModel();
int rows=model.getRowCount();
if(rows>0)
{
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
String query="Select title,author,book_id from books where genre='Kids'";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement stmt=(Statement)con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String btitle=rs.getString("title");
String bauthor=rs.getString("author");
String bbook_id=rs.getString("book_id");
//System.out.println(btitle+"/"+bauthor+"/"+bbook_id);
model.addRow(new Object[]{btitle,bauthor,bbook_id});
}
}
catch(Exception e)
{
JoptionPane.showMessageDialog(this, e.getMessage());
}
//Coding for Next:
new I9().setVisible(true);
this.setVisible(false);
new I7().setVisible(true);
this.setVisible(false);
Page 22 of 43
Order Window
//Import Package:
import java.sql.*;
import javax.swing.table.DefaultTableModel;
Page 24 of 43
ccbook=" Lorna Doone R.D. Blackmore";
else if(clab.getSelectedIndex()==17)
ccbook="Jamaica Inn Daphne du Maurie";
else if(clab.getSelectedIndex()==18)
ccbook="Kidnapped Robert Louis Stevenson";
else if(clab.getSelectedIndex()==19)
ccbook="Treasure Island Robert Louis Stevenson";
else if(clab.getSelectedIndex()==20)
ccbook="The Call of the Wild Jack London";
else if(clab.getSelectedIndex()==21)
ccbook="Charlotte’s Web E.B. White";
else if(clab.getSelectedIndex()==22)
ccbook="The Wind in the Willows Kenneth Grahame";
else if(clab.getSelectedIndex()==23)
ccbook="Moonfleet J. Meade Falkner";
else if(clab.getSelectedIndex()==24)
ccbook="Oliver Twist Charles Dickens";
else if(clab.getSelectedIndex()==25)
ccbook="A Tale of Two Cities Charles Dickens";
else if(clab.getSelectedIndex()==26)
ccbook="Brideshead Revisited Evelyn Waugh";
else if(clab.getSelectedIndex()==27)
ccbook="The Mayor of Casterbridge Thomas Hardy";
else if(clab.getSelectedIndex()==28)
ccbook="Don Quixote Cervantes";
else if(clab.getSelectedIndex()==29)
ccbook="Alice’s Adventures in Wonderland Lewis Carroll";
else if(clab.getSelectedIndex()==30)
ccbook="The Picture of Dorian Gray Oscar Wilde";
else if(clab.getSelectedIndex()==31)
Page 25 of 43
ccbook="Nineteen–Eighty Four George Orwell";
else if(clab.getSelectedIndex()==32)
ccbook="To Kill a Mockingbird Harper Lee";
else if(clab.getSelectedIndex()==33)
ccbook="Tinker Tailor Soldier Spy John le Carré";
else if(clab.getSelectedIndex()==34)
ccbook="Animal Farm George Orwell";
else if(clab.getSelectedIndex()==35)
ccbook="Anne of Green Gables L.M. Montgomery";
DefaultTableModel model=(DefaultTableModel)tab4.getModel();
Page 26 of 43
int rows=model.getRowCount();
if(rows>0)
{
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
String query="Select title,author,book_id from books where genre='Classic'";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String btitle=rs.getString("title");
String bauthor=rs.getString("author");
String bbook_id=rs.getString("book_id");
//System.out.println(btitle+"/"+bauthor+"/"+bbook_id);
model.addRow(new Object[]{btitle,bauthor,bbook_id});
}
}
catch(Exception e)
{
JoptionPane.showMessageDialog(this, e.getMessage());
}
Page 27 of 43
Order Window
//Import Package:
import java.sql.*;
import javax.swing.table.DefaultTableModel;
Page 28 of 43
bbook="The Diary of a Young Girl Anne Frank";
else if(biol.getSelectedIndex()==2)
bbook="Unbroken: A World War II Story of Survival, Resilience, and Redemption
Laura Hillenbrand";
else if(biol.getSelectedIndex()==3)
bbook="John Adams David McCullough";
else if(biol.getSelectedIndex()==4)
bbook="Bossypants (Kindle Edition) Tina Fey ";
else if(biol.getSelectedIndex()==5)
bbook="The Immortal Life of Henrietta Lacks (Hardcover) Rebecca Skloot";
else if(biol.getSelectedIndex()==6)
bbook="Into the Wild Jon Krakauer";
else if(biol.getSelectedIndex()==7)
bbook="I Am Malala: Malala Yousafzai";
else if(biol.getSelectedIndex()==8)
bbook="Night (The Night Trilogy #1) Elie Wiesel ";
else if(biol.getSelectedIndex()==9)
bbook="Benjamin Franklin: An American Life Walter Isaacson";
else if(biol.getSelectedIndex()==10)
bbook="Yes Please (Hardcover) Amy Poehler";
else if(biol.getSelectedIndex()==11)
bbook="Catherine the Great: Portrait of a Woman (Hardcover) Robert K. Massie";
else if(biol.getSelectedIndex()==12)
bbook="Angela's Ashes (Frank McCourt, #1) Frank McCourt";
else if(biol.getSelectedIndex()==13)
bbook="The Glass Castle (Paperback) Jeannette Walls";
else if(biol.getSelectedIndex()==14)
bbook="Surely You're Joking, Mr. Feynman!: Adventures of a Curious Character
(Paperback) Richard Feynman";
else if(biol.getSelectedIndex()==15)
Page 29 of 43
bbook="Team of Rivals: The Political Genius of Abraham Lincoln (Paperback) Doris
Kearns Goodwin ";
else if(biol.getSelectedIndex()==16)
bbook="Alexander Hamilton (Paperback) Ron Chernow ";
else if(biol.getSelectedIndex()==17)
bbook="The Rise of Theodore Roosevelt (Paperback) Edmund Morris";
else if(biol.getSelectedIndex()==18)
bbook="The Autobiography of Benjamin Franklin (Paperback) Benjamin Franklin";
else if(biol.getSelectedIndex()==19)
bbook="I Know Why the Caged Bird Sings (Mass Market Paperback) Maya
Angelou";
else if(biol.getSelectedIndex()==20)
bbook="Wild: From Lost to Found on the Pacific Crest Trail (Hardcover) Cheryl
Strayed";
else if(biol.getSelectedIndex()==21)
bbook="Dreams from My Father: A Story of Race and Inheritance (Paperback)
Barack Obama ";
else if(biol.getSelectedIndex()==22)
bbook="The Hiding Place: The Triumphant True Story of Corrie Ten Boom
(Paperback) Corrie ten Boom";
else if(biol.getSelectedIndex()==23)
bbook="Eat, Pray, Love (Paperback) Elizabeth Gilbert";
else if(biol.getSelectedIndex()==24)
bbook="Elon Musk: Inventing the Future (Hardcover) Ashlee Vance";
else if(biol.getSelectedIndex()==25)
bbook="Washington: A Life (Hardcover) Ron Chernow ";
else if(biol.getSelectedIndex()==26)
bbook="Is Everyone Hanging Out Without Me? (And Other Concerns) Mindy Kaling
";
else if(biol.getSelectedIndex()==27)
Page 30 of 43
bbook="The Wright Brothers (Hardcover) David McCullough";
else if(biol.getSelectedIndex()==28)
bbook="Tuesdays with Morrie (Paperback) Mitch Albom ";
else if(biol.getSelectedIndex()==29)
bbook="Narrative of the Life of Frederick Douglass (Paperback) Frederick
Douglass";
else if(biol.getSelectedIndex()==30)
bbook="Theodore Rex (Paperback) Edmund Morris";
Page 31 of 43
//Coding for Show:
DefaultTableModel model=(DefaultTableModel)tab5.getModel();
int rows=model.getRowCount();
if(rows>0)
{
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
String query="Select title,author,book_id from books where genre='biography'";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/legerit
","root","123");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String btitle=rs.getString("title");
String bauthor=rs.getString("author");
String bbook_id=rs.getString("book_id");
//System.out.println(btitle+"/"+bauthor+"/"+bbook_id);
model.addRow(new Object[]{btitle,bauthor,bbook_id});
}
}
catch(Exception e)
Page 32 of 43
{
JoptionPane.showMessageDialog(this, e.getMessage());
}
new I9().setVisible(true);
this.setVisible(false);
Page 33 of 43
Place Order Window
Page 34 of 43
I12.coml.setText(comedy);
I12.horl.setText(horror);
I12.kidl.setText(kids);
I12.clal.setText(classic);
I12.biogl.setText(biography);
this.setVisible(false);
new I10().setVisible(true);
this.setVisible(false);
Page 35 of 43
Ordered Window
new I13().setVisible(true);
this.setVisible(false);
String a,b,c,d,e;
a=coml.getText();
b=horl.getText();
c=kidl.getText();
d=clal.getText();
e=biogl.getText();
int i = 0;
if(a.equals(" "))
i=0;
else
i++;
if(b.equals(" "))
i=0;
else
i++;
if(c.equals(" "))
Page 36 of 43
i=0;
else
i++;
if(d.equals(" "))
i=0;
else
i++;
if(e.equals(" "))
i=0;
else
i++;
I13.values.setText(""+i);
I13.values.setVisible(false);
new I11().setVisible(true);
this.setVisible(false);
Page 37 of 43
Finalize Order Window
new I6().setVisible(true);
this.setVisible(false);
Page 39 of 43
TABLE USED IN MYSOL
Page 40 of 43
RECORD OF BOOKS WITH BOOK_ID,TITLE, AUTHOR NAME AND GENRE
Page 41 of 43
Page 42 of 43
RECORD OF PERSON HAVING ACCOUNT ON OUR PROGRAMME
Page 43 of 43