SlideShare ist ein Scribd-Unternehmen logo
1 von 15
-Payal Umraliya
DESCLAIMER : THIS CODE IS SIMPLE JAVA CODE WITH APPLET
package ACTUALDATA;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JOptionPane;
import java.util.*;
/**
*
* @author PAYAL
*/
public class retaildetail extends JPanel implements ActionListener
{
JLabel logo,name,resiadd,contct,businessadd,bcontct,faxno,mob,status,children,income,pic,pgr;
JButton in,up,del,exit,f,n,l,p,srch,clr;
JTextField nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm;
JTextArea radd1,badd1;
String t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,na;
Connection cn;
Statement s;
PreparedStatement insrt,dlt,serch,fst,nxt,prv,lst,ext,rst;
Font fnt;
JFrame jf;
//JTable jt;
ResultSet rs;
retaildetail r;
Vector cnames;
String[] rwdt;
public retaildetail()
{
//all labels
fnt=new Font("COMIC SANS SERIF",Font.BOLD,18);
logo=new JLabel("CHECKMATE RETAILERS (YEAR 2014)");
name=new JLabel("

NAME : ");

resiadd=new JLabel(" RESI. ADDRESS :");
contct=new JLabel("

CONTACT :");

businessadd=new JLabel("BUSI.ADDRESS :");
bcontct=new JLabel(" BUSI. CONTACT :");
faxno=new JLabel("

FAX NO :");

mob=new JLabel("

MOBILE :");

pgr=new JLabel("

PAGER :");

status=new JLabel("MARITALSTATUS :");
children=new JLabel("NO.OFCHILDREN :");
income=new JLabel("ANNUALINCOME :");
pic=new JLabel(" PHOTOGRAPH :");

//all textfields nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm;
nm=new JTextField(15);
radd=new JTextField(15);
cnt=new JTextField(15);
badd=new JTextField(15);
bcnt=new JTextField(15);
fx=new JTextField(15);
pc=new JTextField(15);
pg=new JTextField(15);
ms=new JTextField(15);
noc=new JTextField(15);
incm=new JTextField(15);
photo=new JTextField(15);

// all btns in,up,del,exit,f,n,l,p,srch;
in=new JButton("INSERT");
up=new JButton("UPDATE");
del=new JButton("DELETE");
exit=new JButton("EXIT");
f=new JButton("FIRST");
n=new JButton("NEXT");
l=new JButton("LAST");
p=new JButton("PREV");
srch=new JButton("CLICK TO SEARCH CUSTOMER");
clr=new JButton("RESET");
// adding all logo,name,resiadd,contct,businessadd,bcontct,faxno,mob,children,income,pic;
//nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm;
//in,up,del,exit,f,n,l,p,srch;
JLabel jl = new JLabel("================================================================");
add(logo);
add(jl);
add(srch);
JLabel jl3 = new JLabel("

");
add(jl3);
add(name);
add(nm);
add(resiadd);
add(radd);
add(contct);
add(cnt);
add(businessadd);
add(badd);
add(bcontct);
add(bcnt);
add(faxno);
add(fx);
add(mob);
add(pc);
add(pgr);
add(pg);
add(status);
add(ms);
add(children);
add(noc);
add(income);
add(incm);
add(pic);
add(photo);//add(jt);
JLabel jl4 = new JLabel("
add(jl4);

");
JLabel jl2 = new JLabel("================================================================");
add(jl2);
add(in);
add(up);
add(del);
add(f);
add(n);
add(p);
add(l);
add(clr);
add(exit);
//end of adding
in.addActionListener(this);
up.addActionListener(this);
del.addActionListener(this);
srch.addActionListener(this);
f.addActionListener(this);
n.addActionListener(this);
l.addActionListener(this);
p.addActionListener(this);
exit.addActionListener(this);
clr.addActionListener(this);
}
//nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm;
public void connection()
{
try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://localhost/try", "root", "checkmate");
s = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
System.out.println("connected");
JOptionPane.showMessageDialog(jf,"!!!...WELCOME CHECKMATE(96)... !!!n ...YOUR DATABASE
CONNECTION IS ESTABLISHED....n ...YOU CAN ABLE NAVIGATE AND MANAGE ALL DATA OF YOUR CUSTOMERS
NOW...");
viewcheckmatedata();
} catch (SQLException e) {
System.out.println("sorry!!! some problems are occured in connectionn see details " + e);
} catch (ClassNotFoundException ce) {
System.out.println("class not found see detailsn " + ce);
} catch (Exception e) {
System.out.println("some problems are found see detailsn " + e);
}
}
void viewcheckmatedata()
{
try
{
rs=s.executeQuery("select * from cust");
rs.next();
nm.setText(rs.getString(1));
radd.setText(rs.getString(2));
cnt.setText(rs.getString(3));
badd.setText(rs.getString(4));
bcnt.setText(rs.getString(5));
fx.setText(rs.getString(6));
pc.setText(rs.getString(7));
pg.setText(rs.getString(8));
ms.setText(rs.getString(9));
noc.setText(rs.getString(10));
incm.setText(rs.getString(11));
photo.setText(rs.getString(12));
}
catch(Exception e)
{
System.out.println("some problems are found see detailsn " + e);
}
}

void settingdata()
{
try
{
nm.setText(rs.getString("name"));
radd.setText(rs.getString("address"));
cnt.setText(rs.getString("contact"));
badd.setText(rs.getString("businessAddress"));
bcnt.setText(rs.getString("businessContact"));
fx.setText(rs.getString("fax"));
pc.setText(rs.getString("mobile"));
pg.setText(rs.getString("pager"));
ms.setText(rs.getString("maritalstatus"));
noc.setText(rs.getString("children"));
incm.setText(rs.getString("annualincome"));
photo.setText(rs.getString("photos"));
}
catch(SQLException se)
{
System.out.println("some problems occured "+ se);
}
catch(Exception e)
{
System.out.println("some problems occured in either searching or viewingn " + e);
}
}
void resetdata()
{
try {
nm.setText("");
radd.setText("");
cnt.setText("");
badd.setText("");
bcnt.setText("");
fx.setText("");
pc.setText("");
pg.setText("");
ms.setText("");
noc.setText("");
incm.setText("");
photo.setText("");
} catch (Exception e) {
System.out.println("some problems occured in either searching or viewing or navigation or resettingn " +
e);
}
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
try
{
if(str.equals("INSERT"))
{
String insql="insert into cust values(?,?,?,?,?,?,?,?,?,?,?,?)";
insrt=cn.prepareStatement(insql);
insrt.setString(1,nm.getText());//
insrt.setString(2,radd.getText());//
insrt.setInt(3,Integer.parseInt(cnt.getText()));
insrt.setString(4,badd.getText());//
insrt.setInt(5,Integer.parseInt(bcnt.getText()));
insrt.setInt(6,Integer.parseInt(fx.getText()));
insrt.setInt(7,Integer.parseInt(pc.getText()));
insrt.setString(8,pg.getText());//
insrt.setString(9,ms.getText());
insrt.setInt(10,Integer.parseInt(noc.getText()));
insrt.setInt(11,Integer.parseInt(incm.getText()));
insrt.setString(12,photo.getText());//
insrt.executeUpdate();
JOptionPane.showMessageDialog(jf,"1 ROW INSERTED");
System.out.println("Data insereted");
viewcheckmatedata();
}
else if(str.equals("UPDATE"))
{
String na = JOptionPane.showInputDialog("plz enter name which u want to edit");
nm.setText(na);
String insql="update cust set
address=?,contact=?,businessAddress=?,businessContact=?,fax=?,mobile=?,pager=?,maritalstatus=?,children=?,an
nualincome=?,photos=?where name=?";
insrt = cn.prepareStatement(insql);
insrt.setString(1, radd.getText());//
insrt.setInt(2, Integer.parseInt(cnt.getText()));
insrt.setString(3, badd.getText());//
insrt.setInt(4, Integer.parseInt(bcnt.getText()));
insrt.setInt(5, Integer.parseInt(fx.getText()));
insrt.setInt(6, Integer.parseInt(pc.getText()));
insrt.setInt(7, Integer.parseInt(pg.getText()));//
insrt.setString(8, ms.getText());
insrt.setInt(9, Integer.parseInt(noc.getText()));
insrt.setInt(10, Integer.parseInt(incm.getText()));
insrt.setString(11, photo.getText());//
insrt.setString(12,nm.getText());
insrt.executeUpdate();
JOptionPane.showMessageDialog(jf,"1 ROW UPDATED");
System.out.println("DATA UPDATED");
viewcheckmatedata();
}
else if(str.equals("DELETE"))
{
String na = JOptionPane.showInputDialog("enter the name for delete");
nm.setText(na);
System.out.println("query reading");
String insql = "delete from cust where name=?";
dlt = cn.prepareStatement(insql);
System.out.println("preparing");
dlt.setString(1,nm.getText());
System.out.println("deleting " + na);
System.out.println("exeecutes update statement");
dlt.executeUpdate();
JOptionPane.showMessageDialog(jf, "1 ROW DELETED");
System.out.println("DATA DELETED");
viewcheckmatedata();
}
else if(str.equals("CLICK TO SEARCH CUSTOMER"))//nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm;
{
String na = JOptionPane.showInputDialog("enter the name for delete");
nm.setText(na);
String insql="select * from cust where name=?";
serch=cn.prepareStatement(insql);
serch.setString(1, nm.getText());
rs=serch.executeQuery();
rs.next();
JOptionPane.showMessageDialog(jf, "DATA FOUND");
nm.setText(rs.getString(1));
radd.setText(rs.getString(2));
cnt.setText(rs.getString(3));
badd.setText(rs.getString(4));
bcnt.setText(rs.getString(5));
fx.setText(rs.getString(6));
pc.setText(rs.getString(7));
pg.setText(rs.getString(8));
ms.setText(rs.getString(9));
noc.setText(rs.getString(10));
incm.setText(rs.getString(11));
photo.setText(rs.getString(12));
/* if(rs.getString(1)!=na)
{
JOptionPane.showMessageDialog(jf, "NO DATA FOUND AVAILABLE WITH THIS NAME TRY AGAIN ");
// String na2 = JOptionPane.showInputDialog("enter the name for delete");
}*/
}
else if(str.equals("FIRST"))
{
int cntr=1;
cntr++;
rs.first();
settingdata();
}
else if(str.equals("NEXT"))
{
rs.next();
settingdata();

}
else if(str.equals("PREV"))
{
rs.previous();
settingdata();
}
else if(str.equals("LAST"))
{
rs.last();
settingdata();
}
else if (str.equals("RESET"))
{
resetdata();
}
else
{
s.close();
cn.close();
System.exit(0);
}
}
catch(SQLException e)
{
System.out.println("sqlexception check your sqlstatement see detail n " + e);
}
catch(NullPointerException ne)
{
System.out.println("null object referenses are set see detail n " + ne);
}
catch(Exception e)
{
System.out.println("some problems are found see detailsn " + e);
return;
}
}
public static void main(String[] args)
{
// TODO code application logic here
retaildetail r=new retaildetail();
r.connection();
JFrame jf=new JFrame("..........CheckMate(96)............");
jf.setContentPane(r);
jf.setVisible(true);
jf.setSize(300,600);
jf.setResizable(false);
}

}
END OF CODING
-------------------------------------------------------------------------------------------------------------------------------------------------------Database:
-- Database: `checkmate`
-- -------------------------------------------------------hello there my DATABASE name is :--------->checkmate
CREATE TABLE IF NOT EXISTS `cust` (
`name` varchar(20) DEFAULT NULL,
`address` varchar(200) DEFAULT NULL,
`contact` int(20) DEFAULT NULL,
`businessAddress` varchar(200) DEFAULT NULL,
`businessContact` int(20) DEFAULT NULL,
`fax` int(20) DEFAULT NULL,
`mobile` int(20) DEFAULT NULL,
`pager` int(20) DEFAULT NULL,
`maritalstatus` varchar(20) DEFAULT NULL,
`children` int(20) DEFAULT NULL,
`annualincome` int(50) DEFAULT NULL,
`photos` varchar(10000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table `cust`
INSERT INTO `cust` (`name`, `address`, `contact`, `businessAddress`, `businessContact`, `fax`, `mobile`, `pager`,
`maritalstatus`, `children`, `annualincome`, `photos`) VALUES
('payal', '38sagar', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 99000000, 'not available'),
('dhaval', '84shinagar', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 99000000, 'not
available'),
('parth', '3santos', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 999000000, 'not available');

Weitere ähnliche Inhalte

Ähnlich wie CRUD(IN_UP_DEL) IN JAVA

Building Maintainable Applications in Apex
Building Maintainable Applications in ApexBuilding Maintainable Applications in Apex
Building Maintainable Applications in ApexJeffrey Kemp
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfMuhammadMaazShaik
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문NAVER D2
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationAlex Hardman
 
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemRedux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemAdam Klein
 
Xenogenetics for PL/SQL - infusing with Java best practices
Xenogenetics for PL/SQL - infusing with Java best practicesXenogenetics for PL/SQL - infusing with Java best practices
Xenogenetics for PL/SQL - infusing with Java best practicesLucas Jellema
 
Security Events correlation with ESPER
Security Events correlation with ESPERSecurity Events correlation with ESPER
Security Events correlation with ESPERNikolay Klendar
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Presentation aalpert v6а+++
Presentation aalpert v6а+++Presentation aalpert v6а+++
Presentation aalpert v6а+++Natalia Gorak
 
The rise of json in rdbms land jab17
The rise of json in rdbms land jab17The rise of json in rdbms land jab17
The rise of json in rdbms land jab17alikonweb
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17LogeekNightUkraine
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 

Ähnlich wie CRUD(IN_UP_DEL) IN JAVA (20)

Building Maintainable Applications in Apex
Building Maintainable Applications in ApexBuilding Maintainable Applications in Apex
Building Maintainable Applications in Apex
 
Ip project
Ip projectIp project
Ip project
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
 
Android examples
Android examplesAndroid examples
Android examples
 
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemRedux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
 
Xenogenetics
XenogeneticsXenogenetics
Xenogenetics
 
Xenogenetics for PL/SQL - infusing with Java best practices
Xenogenetics for PL/SQL - infusing with Java best practicesXenogenetics for PL/SQL - infusing with Java best practices
Xenogenetics for PL/SQL - infusing with Java best practices
 
Security Events correlation with ESPER
Security Events correlation with ESPERSecurity Events correlation with ESPER
Security Events correlation with ESPER
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Presentation aalpert v6а+++
Presentation aalpert v6а+++Presentation aalpert v6а+++
Presentation aalpert v6а+++
 
The rise of json in rdbms land jab17
The rise of json in rdbms land jab17The rise of json in rdbms land jab17
The rise of json in rdbms land jab17
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Java and xml
Java and xmlJava and xml
Java and xml
 
Vcs23
Vcs23Vcs23
Vcs23
 

Kürzlich hochgeladen

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

CRUD(IN_UP_DEL) IN JAVA

  • 1. -Payal Umraliya DESCLAIMER : THIS CODE IS SIMPLE JAVA CODE WITH APPLET package ACTUALDATA; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; import javax.swing.JOptionPane; import java.util.*; /** * * @author PAYAL */ public class retaildetail extends JPanel implements ActionListener { JLabel logo,name,resiadd,contct,businessadd,bcontct,faxno,mob,status,children,income,pic,pgr; JButton in,up,del,exit,f,n,l,p,srch,clr; JTextField nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm; JTextArea radd1,badd1; String t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,na; Connection cn; Statement s; PreparedStatement insrt,dlt,serch,fst,nxt,prv,lst,ext,rst; Font fnt; JFrame jf; //JTable jt; ResultSet rs;
  • 2. retaildetail r; Vector cnames; String[] rwdt; public retaildetail() { //all labels fnt=new Font("COMIC SANS SERIF",Font.BOLD,18); logo=new JLabel("CHECKMATE RETAILERS (YEAR 2014)"); name=new JLabel(" NAME : "); resiadd=new JLabel(" RESI. ADDRESS :"); contct=new JLabel(" CONTACT :"); businessadd=new JLabel("BUSI.ADDRESS :"); bcontct=new JLabel(" BUSI. CONTACT :"); faxno=new JLabel(" FAX NO :"); mob=new JLabel(" MOBILE :"); pgr=new JLabel(" PAGER :"); status=new JLabel("MARITALSTATUS :"); children=new JLabel("NO.OFCHILDREN :"); income=new JLabel("ANNUALINCOME :"); pic=new JLabel(" PHOTOGRAPH :"); //all textfields nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm; nm=new JTextField(15); radd=new JTextField(15); cnt=new JTextField(15); badd=new JTextField(15); bcnt=new JTextField(15);
  • 3. fx=new JTextField(15); pc=new JTextField(15); pg=new JTextField(15); ms=new JTextField(15); noc=new JTextField(15); incm=new JTextField(15); photo=new JTextField(15); // all btns in,up,del,exit,f,n,l,p,srch; in=new JButton("INSERT"); up=new JButton("UPDATE"); del=new JButton("DELETE"); exit=new JButton("EXIT"); f=new JButton("FIRST"); n=new JButton("NEXT"); l=new JButton("LAST"); p=new JButton("PREV"); srch=new JButton("CLICK TO SEARCH CUSTOMER"); clr=new JButton("RESET"); // adding all logo,name,resiadd,contct,businessadd,bcontct,faxno,mob,children,income,pic; //nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm; //in,up,del,exit,f,n,l,p,srch; JLabel jl = new JLabel("================================================================"); add(logo); add(jl); add(srch); JLabel jl3 = new JLabel(" ");
  • 5. JLabel jl2 = new JLabel("================================================================"); add(jl2); add(in); add(up); add(del); add(f); add(n); add(p); add(l); add(clr); add(exit); //end of adding in.addActionListener(this); up.addActionListener(this); del.addActionListener(this); srch.addActionListener(this); f.addActionListener(this); n.addActionListener(this); l.addActionListener(this); p.addActionListener(this); exit.addActionListener(this); clr.addActionListener(this); } //nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm; public void connection() { try {
  • 6. Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://localhost/try", "root", "checkmate"); s = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); System.out.println("connected"); JOptionPane.showMessageDialog(jf,"!!!...WELCOME CHECKMATE(96)... !!!n ...YOUR DATABASE CONNECTION IS ESTABLISHED....n ...YOU CAN ABLE NAVIGATE AND MANAGE ALL DATA OF YOUR CUSTOMERS NOW..."); viewcheckmatedata(); } catch (SQLException e) { System.out.println("sorry!!! some problems are occured in connectionn see details " + e); } catch (ClassNotFoundException ce) { System.out.println("class not found see detailsn " + ce); } catch (Exception e) { System.out.println("some problems are found see detailsn " + e); } } void viewcheckmatedata() { try { rs=s.executeQuery("select * from cust"); rs.next(); nm.setText(rs.getString(1)); radd.setText(rs.getString(2)); cnt.setText(rs.getString(3)); badd.setText(rs.getString(4)); bcnt.setText(rs.getString(5)); fx.setText(rs.getString(6));
  • 7. pc.setText(rs.getString(7)); pg.setText(rs.getString(8)); ms.setText(rs.getString(9)); noc.setText(rs.getString(10)); incm.setText(rs.getString(11)); photo.setText(rs.getString(12)); } catch(Exception e) { System.out.println("some problems are found see detailsn " + e); } } void settingdata() { try { nm.setText(rs.getString("name")); radd.setText(rs.getString("address")); cnt.setText(rs.getString("contact")); badd.setText(rs.getString("businessAddress")); bcnt.setText(rs.getString("businessContact")); fx.setText(rs.getString("fax")); pc.setText(rs.getString("mobile")); pg.setText(rs.getString("pager")); ms.setText(rs.getString("maritalstatus")); noc.setText(rs.getString("children"));
  • 8. incm.setText(rs.getString("annualincome")); photo.setText(rs.getString("photos")); } catch(SQLException se) { System.out.println("some problems occured "+ se); } catch(Exception e) { System.out.println("some problems occured in either searching or viewingn " + e); } } void resetdata() { try { nm.setText(""); radd.setText(""); cnt.setText(""); badd.setText(""); bcnt.setText(""); fx.setText(""); pc.setText(""); pg.setText(""); ms.setText(""); noc.setText(""); incm.setText(""); photo.setText("");
  • 9. } catch (Exception e) { System.out.println("some problems occured in either searching or viewing or navigation or resettingn " + e); } } public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); try { if(str.equals("INSERT")) { String insql="insert into cust values(?,?,?,?,?,?,?,?,?,?,?,?)"; insrt=cn.prepareStatement(insql); insrt.setString(1,nm.getText());// insrt.setString(2,radd.getText());// insrt.setInt(3,Integer.parseInt(cnt.getText())); insrt.setString(4,badd.getText());// insrt.setInt(5,Integer.parseInt(bcnt.getText())); insrt.setInt(6,Integer.parseInt(fx.getText())); insrt.setInt(7,Integer.parseInt(pc.getText())); insrt.setString(8,pg.getText());// insrt.setString(9,ms.getText()); insrt.setInt(10,Integer.parseInt(noc.getText())); insrt.setInt(11,Integer.parseInt(incm.getText())); insrt.setString(12,photo.getText());// insrt.executeUpdate();
  • 10. JOptionPane.showMessageDialog(jf,"1 ROW INSERTED"); System.out.println("Data insereted"); viewcheckmatedata(); } else if(str.equals("UPDATE")) { String na = JOptionPane.showInputDialog("plz enter name which u want to edit"); nm.setText(na); String insql="update cust set address=?,contact=?,businessAddress=?,businessContact=?,fax=?,mobile=?,pager=?,maritalstatus=?,children=?,an nualincome=?,photos=?where name=?"; insrt = cn.prepareStatement(insql); insrt.setString(1, radd.getText());// insrt.setInt(2, Integer.parseInt(cnt.getText())); insrt.setString(3, badd.getText());// insrt.setInt(4, Integer.parseInt(bcnt.getText())); insrt.setInt(5, Integer.parseInt(fx.getText())); insrt.setInt(6, Integer.parseInt(pc.getText())); insrt.setInt(7, Integer.parseInt(pg.getText()));// insrt.setString(8, ms.getText()); insrt.setInt(9, Integer.parseInt(noc.getText())); insrt.setInt(10, Integer.parseInt(incm.getText())); insrt.setString(11, photo.getText());// insrt.setString(12,nm.getText()); insrt.executeUpdate(); JOptionPane.showMessageDialog(jf,"1 ROW UPDATED"); System.out.println("DATA UPDATED"); viewcheckmatedata();
  • 11. } else if(str.equals("DELETE")) { String na = JOptionPane.showInputDialog("enter the name for delete"); nm.setText(na); System.out.println("query reading"); String insql = "delete from cust where name=?"; dlt = cn.prepareStatement(insql); System.out.println("preparing"); dlt.setString(1,nm.getText()); System.out.println("deleting " + na); System.out.println("exeecutes update statement"); dlt.executeUpdate(); JOptionPane.showMessageDialog(jf, "1 ROW DELETED"); System.out.println("DATA DELETED"); viewcheckmatedata(); } else if(str.equals("CLICK TO SEARCH CUSTOMER"))//nm,radd,cnt,badd,photo,bcnt,fx,pc,pg,ms,noc,incm; { String na = JOptionPane.showInputDialog("enter the name for delete"); nm.setText(na); String insql="select * from cust where name=?"; serch=cn.prepareStatement(insql); serch.setString(1, nm.getText()); rs=serch.executeQuery(); rs.next(); JOptionPane.showMessageDialog(jf, "DATA FOUND");
  • 13. rs.next(); settingdata(); } else if(str.equals("PREV")) { rs.previous(); settingdata(); } else if(str.equals("LAST")) { rs.last(); settingdata(); } else if (str.equals("RESET")) { resetdata(); } else { s.close(); cn.close(); System.exit(0); } } catch(SQLException e) {
  • 14. System.out.println("sqlexception check your sqlstatement see detail n " + e); } catch(NullPointerException ne) { System.out.println("null object referenses are set see detail n " + ne); } catch(Exception e) { System.out.println("some problems are found see detailsn " + e); return; } } public static void main(String[] args) { // TODO code application logic here retaildetail r=new retaildetail(); r.connection(); JFrame jf=new JFrame("..........CheckMate(96)............"); jf.setContentPane(r); jf.setVisible(true); jf.setSize(300,600); jf.setResizable(false); } } END OF CODING
  • 15. -------------------------------------------------------------------------------------------------------------------------------------------------------Database: -- Database: `checkmate` -- -------------------------------------------------------hello there my DATABASE name is :--------->checkmate CREATE TABLE IF NOT EXISTS `cust` ( `name` varchar(20) DEFAULT NULL, `address` varchar(200) DEFAULT NULL, `contact` int(20) DEFAULT NULL, `businessAddress` varchar(200) DEFAULT NULL, `businessContact` int(20) DEFAULT NULL, `fax` int(20) DEFAULT NULL, `mobile` int(20) DEFAULT NULL, `pager` int(20) DEFAULT NULL, `maritalstatus` varchar(20) DEFAULT NULL, `children` int(20) DEFAULT NULL, `annualincome` int(50) DEFAULT NULL, `photos` varchar(10000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- Dumping data for table `cust` INSERT INTO `cust` (`name`, `address`, `contact`, `businessAddress`, `businessContact`, `fax`, `mobile`, `pager`, `maritalstatus`, `children`, `annualincome`, `photos`) VALUES ('payal', '38sagar', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 99000000, 'not available'), ('dhaval', '84shinagar', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 99000000, 'not available'), ('parth', '3santos', 1234567890, 'hyderabad', 678905, 56, 1234567890, 1, 'merried', 2, 999000000, 'not available');