├── LOGIN.java
├── DBConnect.java
├── project1.form
├── project1.java
├── department.form
└── department.java
/LOGIN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
4 | */
5 | package login;
6 |
7 | /**
8 | *
9 | * @author janan
10 | */
11 | public class LOGIN {
12 |
13 | /**
14 | * @param args the command line arguments
15 | */
16 | public static void main(String[] args) {
17 | // TODO code application logic here
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/DBConnect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4 | */
5 | package login;
6 |
7 | /**
8 | *
9 | * @author janan
10 | */
11 | import java.sql.*;
12 | public class DBConnect {
13 | public static void main(String args[]){
14 | try{
15 | //step1 load the driver class
16 | Class.forName("com.mysql.cj.jdbc.Driver");
17 | //step2 create the connection object
18 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Department", "root","Janani@2004");
19 | //step3 create the statement object
20 | Statement stmt=con.createStatement();
21 |
22 | //step4 execute query
23 | //ResultSet rs=stmt.executeQuery("create table employee (empid number(4), empname varchar2(25))");
24 | stmt.executeUpdate("insert into dep_info values(4,'EEE')");
25 | stmt.executeUpdate("update dep_info set dep_info set dep_name='Mech' where dep_code=4");
26 | //ResultSet rs=stmt.executeQuery("select * from dep_info");
27 | //while(rs.next())
28 | //System.out.println(rs.getInt(1)+" "+rs.getString(2));
29 | stmt.executeUpdate("delete from employee");
30 | //step5 close the connection object
31 | con.close();
32 | }catch(Exception e){ System.out.println(e);}
33 | }
34 | }
35 |
36 |
37 |
--------------------------------------------------------------------------------
/project1.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
209 |
--------------------------------------------------------------------------------
/project1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package login;
6 |
7 | /**
8 | *
9 | * @author janan
10 | */
11 | public class project1 extends javax.swing.JFrame {
12 |
13 | /**
14 | * Creates new form project1
15 | */
16 | public project1() {
17 | initComponents();
18 | }
19 |
20 | /**
21 | * This method is called from within the constructor to initialize the form.
22 | * WARNING: Do NOT modify this code. The content of this method is always
23 | * regenerated by the Form Editor.
24 | */
25 | @SuppressWarnings("unchecked")
26 | // //GEN-BEGIN:initComponents
27 | private void initComponents() {
28 |
29 | jPanel1 = new javax.swing.JPanel();
30 | jLabel1 = new javax.swing.JLabel();
31 | jPanel2 = new javax.swing.JPanel();
32 | jLabel2 = new javax.swing.JLabel();
33 | jTextField1 = new javax.swing.JTextField();
34 | jPanel3 = new javax.swing.JPanel();
35 | jLabel3 = new javax.swing.JLabel();
36 | jLabel4 = new javax.swing.JLabel();
37 | jPasswordField1 = new javax.swing.JPasswordField();
38 | jLabel5 = new javax.swing.JLabel();
39 |
40 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
41 |
42 | jPanel1.setBackground(new java.awt.Color(0, 255, 255));
43 |
44 | jLabel1.setBackground(new java.awt.Color(0, 255, 255));
45 | jLabel1.setText("M.KUMARASAMY COLLEGE OF ENGINEERING ");
46 |
47 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
48 | jPanel1.setLayout(jPanel1Layout);
49 | jPanel1Layout.setHorizontalGroup(
50 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
51 | .addGroup(jPanel1Layout.createSequentialGroup()
52 | .addGap(182, 182, 182)
53 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
54 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
55 | );
56 | jPanel1Layout.setVerticalGroup(
57 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
58 | .addGroup(jPanel1Layout.createSequentialGroup()
59 | .addGap(19, 19, 19)
60 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
61 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
62 | );
63 |
64 | jPanel2.setBackground(new java.awt.Color(0, 204, 204));
65 |
66 | jLabel2.setText("USERNAME: ");
67 |
68 | jTextField1.setText("jTextField1");
69 |
70 | jPanel3.setBackground(new java.awt.Color(102, 255, 255));
71 |
72 | jLabel3.setText("M.KUMARASAMY COLLEGE OF ENGINEERING");
73 |
74 | javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
75 | jPanel3.setLayout(jPanel3Layout);
76 | jPanel3Layout.setHorizontalGroup(
77 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78 | .addGroup(jPanel3Layout.createSequentialGroup()
79 | .addGap(214, 214, 214)
80 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE)
81 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
82 | );
83 | jPanel3Layout.setVerticalGroup(
84 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
85 | .addGroup(jPanel3Layout.createSequentialGroup()
86 | .addGap(34, 34, 34)
87 | .addComponent(jLabel3)
88 | .addContainerGap(50, Short.MAX_VALUE))
89 | );
90 |
91 | jLabel4.setText("PASSWORD");
92 |
93 | jPasswordField1.setText("jPasswordField1");
94 | jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
95 | public void actionPerformed(java.awt.event.ActionEvent evt) {
96 | jPasswordField1ActionPerformed(evt);
97 | }
98 | });
99 |
100 | jLabel5.setText("SUBMIT");
101 |
102 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
103 | jPanel2.setLayout(jPanel2Layout);
104 | jPanel2Layout.setHorizontalGroup(
105 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106 | .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
107 | .addGroup(jPanel2Layout.createSequentialGroup()
108 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109 | .addGroup(jPanel2Layout.createSequentialGroup()
110 | .addGap(155, 155, 155)
111 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
112 | .addComponent(jLabel4)
113 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
114 | .addGap(74, 74, 74)
115 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
117 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
118 | .addGroup(jPanel2Layout.createSequentialGroup()
119 | .addGap(238, 238, 238)
120 | .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
121 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
122 | );
123 | jPanel2Layout.setVerticalGroup(
124 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
126 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
127 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
128 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
129 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
130 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
131 | .addGap(51, 51, 51)
132 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
133 | .addComponent(jLabel4)
134 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
135 | .addGap(39, 39, 39)
136 | .addComponent(jLabel5)
137 | .addGap(68, 68, 68))
138 | );
139 |
140 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
141 | getContentPane().setLayout(layout);
142 | layout.setHorizontalGroup(
143 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 | .addGroup(layout.createSequentialGroup()
145 | .addGap(725, 725, 725)
146 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
147 | .addGroup(layout.createSequentialGroup()
148 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
149 | .addContainerGap())
150 | );
151 | layout.setVerticalGroup(
152 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 | .addGroup(layout.createSequentialGroup()
154 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
155 | .addGap(46, 46, 46)
156 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
157 | .addGap(0, 143, Short.MAX_VALUE))
158 | );
159 |
160 | pack();
161 | }// //GEN-END:initComponents
162 |
163 | private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
164 | // TODO add your handling code here:
165 | }//GEN-LAST:event_jPasswordField1ActionPerformed
166 |
167 | /**
168 | * @param args the command line arguments
169 | */
170 | public static void main(String args[]) {
171 | /* Set the Nimbus look and feel */
172 | //
173 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
174 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
175 | */
176 | try {
177 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
178 | if ("Nimbus".equals(info.getName())) {
179 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
180 | break;
181 | }
182 | }
183 | } catch (ClassNotFoundException ex) {
184 | java.util.logging.Logger.getLogger(project1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
185 | } catch (InstantiationException ex) {
186 | java.util.logging.Logger.getLogger(project1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
187 | } catch (IllegalAccessException ex) {
188 | java.util.logging.Logger.getLogger(project1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
189 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
190 | java.util.logging.Logger.getLogger(project1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
191 | }
192 | //
193 |
194 | /* Create and display the form */
195 | java.awt.EventQueue.invokeLater(new Runnable() {
196 | public void run() {
197 | new project1().setVisible(true);
198 | }
199 | });
200 | }
201 |
202 | // Variables declaration - do not modify//GEN-BEGIN:variables
203 | private javax.swing.JLabel jLabel1;
204 | private javax.swing.JLabel jLabel2;
205 | private javax.swing.JLabel jLabel3;
206 | private javax.swing.JLabel jLabel4;
207 | private javax.swing.JLabel jLabel5;
208 | private javax.swing.JPanel jPanel1;
209 | private javax.swing.JPanel jPanel2;
210 | private javax.swing.JPanel jPanel3;
211 | private javax.swing.JPasswordField jPasswordField1;
212 | private javax.swing.JTextField jTextField1;
213 | // End of variables declaration//GEN-END:variables
214 | }
215 |
--------------------------------------------------------------------------------
/department.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
340 |
--------------------------------------------------------------------------------
/department.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package login;
6 |
7 | import java.sql.*;
8 | import javax.swing.table.DefaultTableModel;
9 | public class department extends javax.swing.JFrame{
10 |
11 | /**
12 | *
13 | * @author janan
14 | */
15 | public department(){
16 |
17 | initComponents();
18 | }
19 |
20 |
21 | /**
22 | * This method is called from within the constructor to initialize the form.
23 | * WARNING: Do NOT modify this code. The content of this method is always
24 | * regenerated by the Form Editor.
25 | */
26 | @SuppressWarnings("unchecked")
27 | // //GEN-BEGIN:initComponents
28 | private void initComponents() {
29 |
30 | jPanel6 = new javax.swing.JPanel();
31 | jPanel7 = new javax.swing.JPanel();
32 | jLabel2 = new javax.swing.JLabel();
33 | jPanel8 = new javax.swing.JPanel();
34 | LISTALL = new javax.swing.JButton();
35 | EDIT = new javax.swing.JButton();
36 | DELETE = new javax.swing.JPanel();
37 | jScrollPane2 = new javax.swing.JScrollPane();
38 | deptable = new javax.swing.JTable();
39 | jLabel1 = new javax.swing.JLabel();
40 | deptid = new javax.swing.JTextField();
41 | deptname = new javax.swing.JTextField();
42 | add = new javax.swing.JButton();
43 | update = new javax.swing.JButton();
44 | delete = new javax.swing.JButton();
45 | jLabel3 = new javax.swing.JLabel();
46 | jLabel4 = new javax.swing.JLabel();
47 |
48 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
49 |
50 | jPanel7.setBackground(new java.awt.Color(0, 255, 255));
51 |
52 | jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
53 | jLabel2.setText("M.KUMARASAMY COLLEGE OF ENGINEERING");
54 |
55 | javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
56 | jPanel7.setLayout(jPanel7Layout);
57 | jPanel7Layout.setHorizontalGroup(
58 | jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
59 | .addGroup(jPanel7Layout.createSequentialGroup()
60 | .addGap(119, 119, 119)
61 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE)
62 | .addContainerGap(121, Short.MAX_VALUE))
63 | );
64 | jPanel7Layout.setVerticalGroup(
65 | jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
66 | .addGroup(jPanel7Layout.createSequentialGroup()
67 | .addGap(35, 35, 35)
68 | .addComponent(jLabel2)
69 | .addContainerGap(48, Short.MAX_VALUE))
70 | );
71 |
72 | jPanel8.setBackground(new java.awt.Color(204, 0, 204));
73 |
74 | LISTALL.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
75 | LISTALL.setText("LISTALL");
76 | LISTALL.addActionListener(new java.awt.event.ActionListener() {
77 | public void actionPerformed(java.awt.event.ActionEvent evt) {
78 | LISTALLActionPerformed(evt);
79 | }
80 | });
81 |
82 | EDIT.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
83 | EDIT.setText("EDIT");
84 | EDIT.addActionListener(new java.awt.event.ActionListener() {
85 | public void actionPerformed(java.awt.event.ActionEvent evt) {
86 | EDITActionPerformed(evt);
87 | }
88 | });
89 |
90 | javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
91 | jPanel8.setLayout(jPanel8Layout);
92 | jPanel8Layout.setHorizontalGroup(
93 | jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
94 | .addGroup(jPanel8Layout.createSequentialGroup()
95 | .addGap(33, 33, 33)
96 | .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
97 | .addComponent(EDIT)
98 | .addComponent(LISTALL))
99 | .addContainerGap(36, Short.MAX_VALUE))
100 | );
101 | jPanel8Layout.setVerticalGroup(
102 | jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
103 | .addGroup(jPanel8Layout.createSequentialGroup()
104 | .addGap(100, 100, 100)
105 | .addComponent(LISTALL)
106 | .addGap(99, 99, 99)
107 | .addComponent(EDIT)
108 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
109 | );
110 |
111 | DELETE.setBackground(new java.awt.Color(255, 51, 204));
112 | DELETE.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
113 |
114 | deptable.setModel(new javax.swing.table.DefaultTableModel(
115 | new Object [][] {
116 | {null, null},
117 | {null, null},
118 | {null, null},
119 | {null, null}
120 | },
121 | new String [] {
122 | "DEPARTMENT CODE", "DEPARTMENT NAME"
123 | }
124 | ));
125 | jScrollPane2.setViewportView(deptable);
126 |
127 | add.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
128 | add.setText("ADD");
129 | add.addActionListener(new java.awt.event.ActionListener() {
130 | public void actionPerformed(java.awt.event.ActionEvent evt) {
131 | addActionPerformed(evt);
132 | }
133 | });
134 |
135 | update.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
136 | update.setText("UPDATE");
137 | update.addActionListener(new java.awt.event.ActionListener() {
138 | public void actionPerformed(java.awt.event.ActionEvent evt) {
139 | updateActionPerformed(evt);
140 | }
141 | });
142 |
143 | delete.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
144 | delete.setText("DELETE");
145 | delete.addActionListener(new java.awt.event.ActionListener() {
146 | public void actionPerformed(java.awt.event.ActionEvent evt) {
147 | deleteActionPerformed(evt);
148 | }
149 | });
150 |
151 | jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
152 | jLabel3.setText("DEPT-ID");
153 |
154 | jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
155 | jLabel4.setText("DEPT-NAME");
156 |
157 | javax.swing.GroupLayout DELETELayout = new javax.swing.GroupLayout(DELETE);
158 | DELETE.setLayout(DELETELayout);
159 | DELETELayout.setHorizontalGroup(
160 | DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
161 | .addGroup(DELETELayout.createSequentialGroup()
162 | .addContainerGap()
163 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
164 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
165 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
166 | .addGroup(DELETELayout.createSequentialGroup()
167 | .addComponent(add, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
168 | .addGap(18, 18, 18)
169 | .addComponent(update)
170 | .addGap(26, 26, 26)
171 | .addComponent(delete)
172 | .addGap(0, 0, Short.MAX_VALUE))
173 | .addGroup(DELETELayout.createSequentialGroup()
174 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
175 | .addGroup(DELETELayout.createSequentialGroup()
176 | .addGap(105, 105, 105)
177 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
178 | .addGroup(DELETELayout.createSequentialGroup()
179 | .addGap(34, 34, 34)
180 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
182 | .addComponent(jLabel4))))
183 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
184 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
185 | .addComponent(deptid, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
186 | .addGroup(DELETELayout.createSequentialGroup()
187 | .addGap(7, 7, 7)
188 | .addComponent(deptname)))))
189 | .addContainerGap())
190 | );
191 | DELETELayout.setVerticalGroup(
192 | DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193 | .addGroup(DELETELayout.createSequentialGroup()
194 | .addGap(108, 108, 108)
195 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
196 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
197 | .addGroup(DELETELayout.createSequentialGroup()
198 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
199 | .addComponent(deptid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
200 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
201 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202 | .addComponent(jLabel1)
203 | .addGap(49, 49, 49)
204 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205 | .addComponent(deptname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
206 | .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
207 | .addGap(58, 58, 58)
208 | .addGroup(DELETELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
209 | .addComponent(update)
210 | .addComponent(delete)
211 | .addComponent(add))))
212 | .addContainerGap(153, Short.MAX_VALUE))
213 | );
214 |
215 | javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
216 | jPanel6.setLayout(jPanel6Layout);
217 | jPanel6Layout.setHorizontalGroup(
218 | jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219 | .addGroup(jPanel6Layout.createSequentialGroup()
220 | .addGap(34, 34, 34)
221 | .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
222 | .addGroup(jPanel6Layout.createSequentialGroup()
223 | .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
224 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
225 | .addComponent(DELETE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
226 | .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
227 | .addContainerGap(67, Short.MAX_VALUE))
228 | );
229 | jPanel6Layout.setVerticalGroup(
230 | jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
231 | .addGroup(jPanel6Layout.createSequentialGroup()
232 | .addGap(19, 19, 19)
233 | .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
234 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
235 | .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236 | .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
237 | .addComponent(DELETE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
238 | .addContainerGap())
239 | );
240 |
241 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
242 | getContentPane().setLayout(layout);
243 | layout.setHorizontalGroup(
244 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245 | .addGroup(layout.createSequentialGroup()
246 | .addContainerGap()
247 | .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
248 | .addContainerGap(1685, Short.MAX_VALUE))
249 | );
250 | layout.setVerticalGroup(
251 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
252 | .addGroup(layout.createSequentialGroup()
253 | .addContainerGap()
254 | .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
255 | .addGap(0, 460, Short.MAX_VALUE))
256 | );
257 |
258 | pack();
259 | }// //GEN-END:initComponents
260 |
261 | private void LISTALLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LISTALLActionPerformed
262 | // TODO add your handling code here:
263 | listTable();
264 | }//GEN-LAST:event_LISTALLActionPerformed
265 |
266 | private void EDITActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EDITActionPerformed
267 | // TODO add your handling code here:
268 | DefaultTableModel model = (DefaultTableModel)deptable.getModel();
269 | deptid.setText(model.getValueAt(row,0).toString());
270 | deptname.setText(model.getValueAt(row,1).toString());
271 | }//GEN-LAST:event_EDITActionPerformed
272 |
273 | private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
274 | // TODO add your handling code here:
275 | int dcode= Integer.parseInt(deptid.getText());
276 | String dname = deptname.getText();
277 | try{
278 | //step1 load the driver class
279 | Class.forName("com.mysql.cj.jdbc.Driver");
280 | //step2 create the connection object
281 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/department", "root","Janani@2004");
282 | //step3 create the statement object
283 | Statement stmt=con.createStatement();
284 | stmt.executeUpdate("update dep_info set dep_name='"+dname+"' where dep_id="+dcode+"");
285 | con.close();
286 | }catch(Exception e){ System.out.println(e);}
287 | deptid.setText("");
288 | deptname.setText("");
289 | listTable();
290 | }//GEN-LAST:event_deleteActionPerformed
291 |
292 | private void updateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateActionPerformed
293 | // TODO add your handling code here:
294 | int dcode= Integer.parseInt(deptid.getText());
295 | String dname = deptname.getText();
296 | try{
297 | //step1 load the driver class
298 | Class.forName("com.mysql.cj.jdbc.Driver");
299 | //step2 create the connection object
300 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/department", "root","Janani@2004");
301 | //step3 create the statement object
302 | Statement stmt=con.createStatement();
303 | stmt.executeUpdate("update dep_info set dep_name='"+dname+"' where dep_id="+dcode+"");
304 | con.close();
305 | }catch(Exception e){ System.out.println(e);}
306 | deptid.setText("");
307 | deptname.setText("");
308 | listTable();
309 |
310 | }//GEN-LAST:event_updateActionPerformed
311 |
312 | private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
313 | // TODO add your handling code here:
314 | int dcode= Integer.parseInt(deptid.getText());
315 | String dname = deptname.getText();
316 | try{
317 | //step1 load the driver class
318 | Class.forName("com.mysql.cj.jdbc.Driver");
319 | //step2 create the connection object
320 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Department","root","Janani@2004");
321 | //step3 create the statement object
322 | Statement stmt=con.createStatement();
323 | //step4 execute query
324 | //ResultSet rs=stmt.executeQuery("create table employee (empid number(4), empname varchar2(25))");
325 | stmt.executeUpdate("insert into dep_info values("+dcode+",'"+dname+"')");
326 | //stmt.executeUpdate("update dep_info set dep_name='IT' where dep_code=3");
327 | //ResultSet rs=stmt.executeQuery("select * from employee");
328 | //while(rs.next())
329 | //System.out.println(rs.getInt(1)+" "+rs.getString(2));
330 | //stmt.executeUpdate("delete from dep_info where dep_id=3");
331 | //step5 close the connection object
332 | con.close();
333 | }catch(Exception e){ System.out.println(e);}
334 | deptid.setText("");
335 | deptname.setText("");
336 | listTable();
337 | }//GEN-LAST:event_addActionPerformed
338 |
339 | /**
340 | * @param args the command line arguments
341 | */
342 | public void listTable(){
343 | DefaultTableModel model = (DefaultTableModel)deptable.getModel();
344 | while(model.getRowCount()>0){
345 | for(int i=0;i
375 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
376 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
377 | */
378 | try {
379 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
380 | if ("Nimbus".equals(info.getName())) {
381 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
382 | break;
383 | }
384 | }
385 | } catch (ClassNotFoundException ex) {
386 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
387 | } catch (InstantiationException ex) {
388 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
389 | } catch (IllegalAccessException ex) {
390 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
391 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
392 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
393 | }
394 | //
395 |
396 | /* Create and display the form */
397 | java.awt.EventQueue.invokeLater(new Runnable() {
398 | public void run() {
399 | new department().setVisible(true);
400 | }
401 | });
402 | }
403 |
404 | // Variables declaration - do not modify//GEN-BEGIN:variables
405 | private javax.swing.JPanel DELETE;
406 | private javax.swing.JButton EDIT;
407 | private javax.swing.JButton LISTALL;
408 | private javax.swing.JButton add;
409 | private javax.swing.JButton delete;
410 | private javax.swing.JTable deptable;
411 | private javax.swing.JTextField deptid;
412 | private javax.swing.JTextField deptname;
413 | private javax.swing.JLabel jLabel1;
414 | private javax.swing.JLabel jLabel2;
415 | private javax.swing.JLabel jLabel3;
416 | private javax.swing.JLabel jLabel4;
417 | private javax.swing.JPanel jPanel6;
418 | private javax.swing.JPanel jPanel7;
419 | private javax.swing.JPanel jPanel8;
420 | private javax.swing.JScrollPane jScrollPane2;
421 | private javax.swing.JButton update;
422 | // End of variables declaration//GEN-END:variables
423 | }
--------------------------------------------------------------------------------