├── LOGIN.form ├── LOGIN.java ├── department.form └── department.java /LOGIN.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 |
165 | -------------------------------------------------------------------------------- /LOGIN.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 javatask; 6 | 7 | /** 8 | * 9 | * @author Admin 10 | */ 11 | public class LOGIN extends javax.swing.JFrame { 12 | 13 | /** 14 | * Creates new form LOGIN 15 | */ 16 | public LOGIN() { 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 | jScrollPane3 = new javax.swing.JScrollPane(); 30 | jTextArea3 = new javax.swing.JTextArea(); 31 | jPanel1 = new javax.swing.JPanel(); 32 | jLabel1 = new javax.swing.JLabel(); 33 | jPanel2 = new javax.swing.JPanel(); 34 | jLabel2 = new javax.swing.JLabel(); 35 | jLabel3 = new javax.swing.JLabel(); 36 | jTextField1 = new javax.swing.JTextField(); 37 | jPasswordField1 = new javax.swing.JPasswordField(); 38 | jButton1 = new javax.swing.JButton(); 39 | 40 | jTextArea3.setColumns(20); 41 | jTextArea3.setRows(5); 42 | jScrollPane3.setViewportView(jTextArea3); 43 | 44 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 45 | 46 | jPanel1.setBackground(new java.awt.Color(0, 255, 204)); 47 | 48 | jLabel1.setText("LOGIN PAGE"); 49 | 50 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 51 | jPanel1.setLayout(jPanel1Layout); 52 | jPanel1Layout.setHorizontalGroup( 53 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 54 | .addGroup(jPanel1Layout.createSequentialGroup() 55 | .addGap(160, 160, 160) 56 | .addComponent(jLabel1) 57 | .addContainerGap(173, Short.MAX_VALUE)) 58 | ); 59 | jPanel1Layout.setVerticalGroup( 60 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 61 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 62 | .addContainerGap(35, Short.MAX_VALUE) 63 | .addComponent(jLabel1) 64 | .addGap(30, 30, 30)) 65 | ); 66 | 67 | jLabel2.setText("username"); 68 | 69 | jLabel3.setText("password"); 70 | 71 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 72 | public void actionPerformed(java.awt.event.ActionEvent evt) { 73 | jTextField1ActionPerformed(evt); 74 | } 75 | }); 76 | 77 | jButton1.setText("SUBMIT"); 78 | 79 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 80 | jPanel2.setLayout(jPanel2Layout); 81 | jPanel2Layout.setHorizontalGroup( 82 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 83 | .addGroup(jPanel2Layout.createSequentialGroup() 84 | .addGap(43, 43, 43) 85 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 86 | .addComponent(jLabel2) 87 | .addComponent(jLabel3)) 88 | .addGap(47, 47, 47) 89 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 90 | .addComponent(jButton1) 91 | .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE) 92 | .addComponent(jPasswordField1)) 93 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 94 | ); 95 | jPanel2Layout.setVerticalGroup( 96 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 97 | .addGroup(jPanel2Layout.createSequentialGroup() 98 | .addGap(35, 35, 35) 99 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 100 | .addComponent(jLabel2) 101 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 102 | .addGap(26, 26, 26) 103 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 104 | .addComponent(jLabel3) 105 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 106 | .addGap(18, 18, 18) 107 | .addComponent(jButton1) 108 | .addContainerGap(20, Short.MAX_VALUE)) 109 | ); 110 | 111 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 112 | getContentPane().setLayout(layout); 113 | layout.setHorizontalGroup( 114 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 115 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 116 | .addGroup(layout.createSequentialGroup() 117 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 118 | .addContainerGap()) 119 | ); 120 | layout.setVerticalGroup( 121 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 122 | .addGroup(layout.createSequentialGroup() 123 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 125 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 126 | .addContainerGap()) 127 | ); 128 | 129 | pack(); 130 | }// //GEN-END:initComponents 131 | 132 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed 133 | // TODO add your handling code here: 134 | }//GEN-LAST:event_jTextField1ActionPerformed 135 | 136 | /** 137 | * @param args the command line arguments 138 | */ 139 | public static void main(String args[]) { 140 | /* Set the Nimbus look and feel */ 141 | // 142 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 143 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 144 | */ 145 | try { 146 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 147 | if ("Nimbus".equals(info.getName())) { 148 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 149 | break; 150 | } 151 | } 152 | } catch (ClassNotFoundException ex) { 153 | java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 154 | } catch (InstantiationException ex) { 155 | java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 156 | } catch (IllegalAccessException ex) { 157 | java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 158 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 159 | java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 160 | } 161 | // 162 | 163 | /* Create and display the form */ 164 | java.awt.EventQueue.invokeLater(new Runnable() { 165 | public void run() { 166 | new LOGIN().setVisible(true); 167 | } 168 | }); 169 | } 170 | 171 | // Variables declaration - do not modify//GEN-BEGIN:variables 172 | private javax.swing.JButton jButton1; 173 | private javax.swing.JLabel jLabel1; 174 | private javax.swing.JLabel jLabel2; 175 | private javax.swing.JLabel jLabel3; 176 | private javax.swing.JPanel jPanel1; 177 | private javax.swing.JPanel jPanel2; 178 | private javax.swing.JPasswordField jPasswordField1; 179 | private javax.swing.JScrollPane jScrollPane3; 180 | private javax.swing.JTextArea jTextArea3; 181 | private javax.swing.JTextField jTextField1; 182 | // End of variables declaration//GEN-END:variables 183 | } 184 | -------------------------------------------------------------------------------- /department.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 |
23 |
24 |
25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 |
229 |
230 | 231 | 232 | 233 | 234 | <Editor/> 235 | <Renderer/> 236 | </Column> 237 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 238 | <Title/> 239 | <Editor/> 240 | <Renderer/> 241 | </Column> 242 | </TableColumnModel> 243 | </Property> 244 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 245 | <TableHeader reorderingAllowed="true" resizingAllowed="true"/> 246 | </Property> 247 | </Properties> 248 | </Component> 249 | </SubComponents> 250 | </Container> 251 | </SubComponents> 252 | </Form> 253 | -------------------------------------------------------------------------------- /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 javatask; 6 | 7 | import java.sql.*; 8 | import javax.swing.table.DefaultTableModel; 9 | 10 | 11 | /** 12 | * 13 | * @author Admin 14 | */ 15 | public class department extends javax.swing.JFrame { 16 | 17 | /** 18 | * Creates new form department 19 | */ 20 | public department() { 21 | initComponents(); 22 | } 23 | 24 | /** 25 | * This method is called from within the constructor to initialize the form. 26 | * WARNING: Do NOT modify this code. The content of this method is always 27 | * regenerated by the Form Editor. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 31 | private void initComponents() { 32 | 33 | jScrollPane1 = new javax.swing.JScrollPane(); 34 | jTable1 = new javax.swing.JTable(); 35 | jScrollPane2 = new javax.swing.JScrollPane(); 36 | jTable2 = new javax.swing.JTable(); 37 | jPanel1 = new javax.swing.JPanel(); 38 | jLabel1 = new javax.swing.JLabel(); 39 | jPanel2 = new javax.swing.JPanel(); 40 | jButton1 = new javax.swing.JButton(); 41 | jPanel3 = new javax.swing.JPanel(); 42 | jScrollPane3 = new javax.swing.JScrollPane(); 43 | deptable = new javax.swing.JTable(); 44 | 45 | jTable1.setModel(new javax.swing.table.DefaultTableModel( 46 | new Object [][] { 47 | {null, null, null, null}, 48 | {null, null, null, null}, 49 | {null, null, null, null}, 50 | {null, null, null, null} 51 | }, 52 | new String [] { 53 | "Title 1", "Title 2", "Title 3", "Title 4" 54 | } 55 | )); 56 | jScrollPane1.setViewportView(jTable1); 57 | 58 | jTable2.setModel(new javax.swing.table.DefaultTableModel( 59 | new Object [][] { 60 | {null, null, null, null}, 61 | {null, null, null, null}, 62 | {null, null, null, null}, 63 | {null, null, null, null} 64 | }, 65 | new String [] { 66 | "Title 1", "Title 2", "Title 3", "Title 4" 67 | } 68 | )); 69 | jScrollPane2.setViewportView(jTable2); 70 | 71 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 72 | setBackground(new java.awt.Color(255, 204, 204)); 73 | 74 | jPanel1.setBackground(new java.awt.Color(255, 255, 204)); 75 | 76 | jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N 77 | jLabel1.setForeground(new java.awt.Color(0, 0, 153)); 78 | jLabel1.setText("M KUMARASAMY COLLEGE OF ENGINEERING"); 79 | 80 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 81 | jPanel1.setLayout(jPanel1Layout); 82 | jPanel1Layout.setHorizontalGroup( 83 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 84 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 85 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 86 | .addComponent(jLabel1) 87 | .addGap(105, 105, 105)) 88 | ); 89 | jPanel1Layout.setVerticalGroup( 90 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 91 | .addGroup(jPanel1Layout.createSequentialGroup() 92 | .addGap(29, 29, 29) 93 | .addComponent(jLabel1) 94 | .addContainerGap(30, Short.MAX_VALUE)) 95 | ); 96 | 97 | jPanel2.setBackground(new java.awt.Color(204, 255, 204)); 98 | 99 | jButton1.setText("List All"); 100 | jButton1.addActionListener(new java.awt.event.ActionListener() { 101 | public void actionPerformed(java.awt.event.ActionEvent evt) { 102 | jButton1ActionPerformed(evt); 103 | } 104 | }); 105 | 106 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 107 | jPanel2.setLayout(jPanel2Layout); 108 | jPanel2Layout.setHorizontalGroup( 109 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 110 | .addGroup(jPanel2Layout.createSequentialGroup() 111 | .addGap(60, 60, 60) 112 | .addComponent(jButton1) 113 | .addContainerGap(77, Short.MAX_VALUE)) 114 | ); 115 | jPanel2Layout.setVerticalGroup( 116 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 117 | .addGroup(jPanel2Layout.createSequentialGroup() 118 | .addGap(18, 18, 18) 119 | .addComponent(jButton1) 120 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 121 | ); 122 | 123 | jPanel3.setBackground(new java.awt.Color(255, 204, 204)); 124 | 125 | javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); 126 | jPanel3.setLayout(jPanel3Layout); 127 | jPanel3Layout.setHorizontalGroup( 128 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 129 | .addGap(0, 453, Short.MAX_VALUE) 130 | ); 131 | jPanel3Layout.setVerticalGroup( 132 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 133 | .addGap(0, 0, Short.MAX_VALUE) 134 | ); 135 | 136 | deptable.setModel(new javax.swing.table.DefaultTableModel( 137 | new Object [][] { 138 | {null, null}, 139 | {null, null}, 140 | {null, null}, 141 | {null, null} 142 | }, 143 | new String [] { 144 | "Department Code", "Department Name" 145 | } 146 | )); 147 | jScrollPane3.setViewportView(deptable); 148 | 149 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 150 | getContentPane().setLayout(layout); 151 | layout.setHorizontalGroup( 152 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 153 | .addGroup(layout.createSequentialGroup() 154 | .addContainerGap() 155 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 156 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 157 | .addGroup(layout.createSequentialGroup() 158 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 159 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 160 | .addGroup(layout.createSequentialGroup() 161 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 162 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 163 | .addGroup(layout.createSequentialGroup() 164 | .addGap(28, 28, 28) 165 | .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))))) 166 | .addContainerGap(14, Short.MAX_VALUE)) 167 | ); 168 | layout.setVerticalGroup( 169 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 170 | .addGroup(layout.createSequentialGroup() 171 | .addContainerGap() 172 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 173 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 174 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 175 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 176 | .addGroup(layout.createSequentialGroup() 177 | .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 178 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 179 | .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE) 180 | .addGap(229, 229, 229))) 181 | .addContainerGap()) 182 | ); 183 | 184 | pack(); 185 | }// </editor-fold>//GEN-END:initComponents 186 | 187 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 188 | // TODO add your handling code here: 189 | DefaultTableModel model=(DefaultTableModel)deptable.getModel(); 190 | while (model.getRowCount()>0) 191 | { 192 | for (int i=0;i<model.getRowCount();i++) 193 | { 194 | model.removeRow(i);}} 195 | try{ 196 | //step1 load the driver class 197 | Class.forName("com.mysql.cj.jdbc.Driver"); 198 | //step2 create the connection object 199 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/department", "root","root"); 200 | //step3 create the statement object 201 | Statement stmt=con.createStatement(); 202 | 203 | //step4 execute query 204 | //ResultSet rs=stmt.executeQuery("create table employee (empid number(4), empname varchar2(25))"); 205 | //ResultSet rs=stmt.executeQuery("insert into employee values(1002, 'Rajesh')"); 206 | //stmt.executeUpdate("update employee set empname=‘Aravind' where empid=120"); 207 | ResultSet rs=stmt.executeQuery("select * from dep_info"); 208 | while(rs.next()){ 209 | object [] data={rs.getInt(1),rs.getString(2)}; 210 | model.addRow(data); 211 | } 212 | 213 | 214 | 215 | System.out.println(rs.getInt(1)+" "+rs.getString(2)); 216 | //ResultSet rs=stmt.executeQuery("delete from employee"); 217 | //step5 close the connection object 218 | con.close(); 219 | }catch(Exception e){ System.out.println(e);} 220 | 221 | }//GEN-LAST:event_jButton1ActionPerformed 222 | 223 | /** 224 | * @param args the command line arguments 225 | */ 226 | public static void main(String args[]) { 227 | /* Set the Nimbus look and feel */ 228 | //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> 229 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 230 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 231 | */ 232 | try { 233 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 234 | if ("Nimbus".equals(info.getName())) { 235 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 236 | break; 237 | } 238 | } 239 | } catch (ClassNotFoundException ex) { 240 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 241 | } catch (InstantiationException ex) { 242 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 243 | } catch (IllegalAccessException ex) { 244 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 245 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 246 | java.util.logging.Logger.getLogger(department.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 247 | } 248 | //</editor-fold> 249 | 250 | /* Create and display the form */ 251 | java.awt.EventQueue.invokeLater(new Runnable() { 252 | public void run() { 253 | new department().setVisible(true); 254 | } 255 | }); 256 | } 257 | 258 | // Variables declaration - do not modify//GEN-BEGIN:variables 259 | private javax.swing.JTable deptable; 260 | private javax.swing.JButton jButton1; 261 | private javax.swing.JLabel jLabel1; 262 | private javax.swing.JPanel jPanel1; 263 | private javax.swing.JPanel jPanel2; 264 | private javax.swing.JPanel jPanel3; 265 | private javax.swing.JScrollPane jScrollPane1; 266 | private javax.swing.JScrollPane jScrollPane2; 267 | private javax.swing.JScrollPane jScrollPane3; 268 | private javax.swing.JTable jTable1; 269 | private javax.swing.JTable jTable2; 270 | // End of variables declaration//GEN-END:variables 271 | } 272 | --------------------------------------------------------------------------------