Question: How can I made it to make change in SQL using Java( need the code- the statements I must use ) ? this is my
How can I made it to make change in SQL using Java( need the code- the statements I must use ) ? this is my connection that I use in UNI : "jdbc:oracle:thin:@coestudb.qu.edu.qa:1521/STUD.qu.edu.qa" , "aa1300228","aa1300228");
** please check for me If I have to add any conditions or methods to let it work good ! this code that I made for the JFrame :
package projectPhase2;
import java.awt.EventQueue;
import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import java.awt.Font; import javax.swing.JPopupMenu; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JTextField; import javax.swing.JLabel;
@SuppressWarnings("serial") public class Update extends JFrame {
private JPanel contentPane; private JTextField textField; private JTextField textField_1; private JTextField textField_2; private JTextField textField_3; private JTextField textField_4; private DBase db = new DBase();
/** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Update frame = new Update(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * Create the frame. */ public Update() { setTitle("Update"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 554, 537); contentPane = new JPanel(); contentPane.setToolTipText("Quantity"); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); JLabel lblQuantity = new JLabel("Item :"); lblQuantity.setBounds(10, 18, 103, 35); lblQuantity.setFont(new Font("Tahoma", Font.BOLD, 21)); JLabel lblCustomerInformation = new JLabel("Customer Information :"); lblCustomerInformation.setBounds(10, 106, 250, 26); lblCustomerInformation.setFont(new Font("Tahoma", Font.BOLD, 21)); JLabel lblOrder = new JLabel("Order :"); lblOrder.setBounds(10, 260, 92, 26); lblOrder.setFont(new Font("Tahoma", Font.BOLD, 21)); JLabel lblQuantity_1 = new JLabel("Quantity"); lblQuantity_1.setBounds(20, 61, 92, 26); JSpinner spinner = new JSpinner(); spinner.setBounds(194, 58, 59, 32); spinner.setModel(new SpinnerNumberModel(0, 0, 100, 1)); spinner.setToolTipText(""); JLabel lblEmail = new JLabel("Email"); lblEmail.setBounds(21, 146, 92, 26); textField = new JTextField(); textField.setBounds(194, 143, 250, 32); textField.setColumns(10); JLabel lblPhoneNumber = new JLabel("Phone No."); lblPhoneNumber.setBounds(21, 184, 116, 26); textField_1 = new JTextField(); textField_1.setBounds(194, 181, 250, 32); textField_1.setColumns(10); JLabel lblBankName = new JLabel("Bank Name"); lblBankName.setBounds(21, 220, 116, 26); textField_2 = new JTextField(); textField_2.setBounds(194, 217, 250, 32); textField_2.setColumns(10); JLabel lbldelivaryDate = new JLabel("Delivary Date"); lbldelivaryDate.setBounds(20, 298, 134, 26); textField_3 = new JTextField(); textField_3.setBounds(194, 295, 250, 32); textField_3.setColumns(10); JLabel lblAddress = new JLabel("Address"); lblAddress.setBounds(21, 340, 92, 26); textField_4 = new JTextField(); textField_4.setBounds(194, 337, 250, 32); textField_4.setColumns(10); JButton btnApply = new JButton("Apply"); btnApply.setBounds(66, 415, 177, 35); btnApply.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int Quantity = spinner.getComponentCount(); String Email = textField.getText(); int PhoneNumber= Integer.parseInt(textField_1.getText()); String BankName= textField_2.getText(); String delivaryDate = textField_3.getText(); String Address = textField_4.getText(); // check the tables and how to update them using java !! // db.Update(Quantity, Email, PhoneNumber, BankName, delivaryDate, Address); //System.out.println("Quantity"+""+"Email"+""+"PhoneNo"+""+"BankName"+""+"DelivaryDate"+""+"Address"); db.UpdateCustomerrr(PhoneNumber, BankName, Email); System.out.println("PhoneNumber"+""+"BankName"+""+"Email"); db.Updateorderr(delivaryDate, Address); System.out.println("delivaryDate"+""+"Address"); } }); JButton btnExit = new JButton("Exit"); btnExit.setBounds(326, 415, 141, 35); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { dispose(); } }); contentPane.setLayout(null); contentPane.add(lblQuantity); contentPane.add(lblCustomerInformation); contentPane.add(lblOrder); contentPane.add(lblQuantity_1); contentPane.add(spinner); contentPane.add(lblEmail); contentPane.add(textField); contentPane.add(lblPhoneNumber); contentPane.add(textField_1); contentPane.add(lblBankName); contentPane.add(textField_2); contentPane.add(lbldelivaryDate); contentPane.add(textField_3); contentPane.add(lblAddress); contentPane.add(textField_4); contentPane.add(btnApply); contentPane.add(btnExit); } @SuppressWarnings("unused") private static void addPopup(Component component, final JPopupMenu popup) { component.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } private void showMenu(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY()); } }); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
