├── LoginForm.form ├── LoginForm.java ├── README.md ├── department.form ├── department.java └── sql.sql /LoginForm.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 | -------------------------------------------------------------------------------- /LoginForm.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 task; 6 | 7 | import java.util.Scanner; 8 | public class LoginForm extends javax.swing.JFrame { 9 | 10 | /** 11 | * Creates new form LoginForm 12 | */ 13 | public LoginForm() { 14 | initComponents(); 15 | } 16 | 17 | /** 18 | * This method is called from within the constructor to initialize the form. 19 | * WARNING: Do NOT modify this code. The content of this method is always 20 | * regenerated by the Form Editor. 21 | */ 22 | @SuppressWarnings("unchecked") 23 | // //GEN-BEGIN:initComponents 24 | private void initComponents() { 25 | 26 | jPopupMenu1 = new javax.swing.JPopupMenu(); 27 | jPanel1 = new javax.swing.JPanel(); 28 | jLabel1 = new javax.swing.JLabel(); 29 | jLabel2 = new javax.swing.JLabel(); 30 | jLabel3 = new javax.swing.JLabel(); 31 | jTextField1 = new javax.swing.JTextField(); 32 | jPasswordField1 = new javax.swing.JPasswordField(); 33 | jButton1 = new javax.swing.JButton(); 34 | jButton2 = new javax.swing.JButton(); 35 | 36 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 37 | setBackground(new java.awt.Color(0, 0, 204)); 38 | addHierarchyListener(new java.awt.event.HierarchyListener() { 39 | public void hierarchyChanged(java.awt.event.HierarchyEvent evt) { 40 | formHierarchyChanged(evt); 41 | } 42 | }); 43 | 44 | jPanel1.setBackground(new java.awt.Color(204, 204, 255)); 45 | 46 | jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N 47 | jLabel1.setForeground(new java.awt.Color(0, 0, 204)); 48 | jLabel1.setText("DEPARTMENT"); 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(155, 155, 155) 56 | .addComponent(jLabel1) 57 | .addContainerGap(157, Short.MAX_VALUE)) 58 | ); 59 | jPanel1Layout.setVerticalGroup( 60 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 61 | .addGroup(jPanel1Layout.createSequentialGroup() 62 | .addGap(14, 14, 14) 63 | .addComponent(jLabel1) 64 | .addContainerGap(14, Short.MAX_VALUE)) 65 | ); 66 | 67 | jLabel1.getAccessibleContext().setAccessibleName("LOGIN PAGE"); 68 | 69 | jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N 70 | jLabel2.setText("Username :"); 71 | 72 | jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N 73 | jLabel3.setText("Password :"); 74 | 75 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 76 | public void actionPerformed(java.awt.event.ActionEvent evt) { 77 | jTextField1ActionPerformed(evt); 78 | } 79 | }); 80 | 81 | jPasswordField1.addActionListener(new java.awt.event.ActionListener() { 82 | public void actionPerformed(java.awt.event.ActionEvent evt) { 83 | jPasswordField1ActionPerformed(evt); 84 | } 85 | }); 86 | 87 | jButton1.setText("Submit"); 88 | jButton1.addActionListener(new java.awt.event.ActionListener() { 89 | public void actionPerformed(java.awt.event.ActionEvent evt) { 90 | jButton1ActionPerformed(evt); 91 | } 92 | }); 93 | 94 | jButton2.setText("Cancel"); 95 | jButton2.addActionListener(new java.awt.event.ActionListener() { 96 | public void actionPerformed(java.awt.event.ActionEvent evt) { 97 | jButton2ActionPerformed(evt); 98 | } 99 | }); 100 | 101 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 102 | getContentPane().setLayout(layout); 103 | layout.setHorizontalGroup( 104 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 105 | .addGroup(layout.createSequentialGroup() 106 | .addGap(6, 6, 6) 107 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 108 | .addGap(0, 8, Short.MAX_VALUE)) 109 | .addGroup(layout.createSequentialGroup() 110 | .addGap(138, 138, 138) 111 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 112 | .addGroup(layout.createSequentialGroup() 113 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) 114 | .addGap(6, 6, 6) 115 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)) 116 | .addGroup(layout.createSequentialGroup() 117 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 118 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) 119 | .addComponent(jButton1)) 120 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 121 | .addGroup(layout.createSequentialGroup() 122 | .addGap(6, 6, 6) 123 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)) 124 | .addGroup(layout.createSequentialGroup() 125 | .addGap(50, 50, 50) 126 | .addComponent(jButton2))))) 127 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 128 | ); 129 | layout.setVerticalGroup( 130 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 131 | .addGroup(layout.createSequentialGroup() 132 | .addGap(6, 6, 6) 133 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 134 | .addGap(64, 64, 64) 135 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 136 | .addComponent(jLabel2) 137 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 138 | .addGap(26, 26, 26) 139 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 140 | .addComponent(jLabel3) 141 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 142 | .addGap(51, 51, 51) 143 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 144 | .addComponent(jButton1) 145 | .addComponent(jButton2)) 146 | .addContainerGap(84, Short.MAX_VALUE)) 147 | ); 148 | 149 | pack(); 150 | }// //GEN-END:initComponents 151 | 152 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed 153 | // TODO add your handling code here: 154 | }//GEN-LAST:event_jTextField1ActionPerformed 155 | 156 | private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed 157 | // TODO add your handling code here: 158 | }//GEN-LAST:event_jPasswordField1ActionPerformed 159 | 160 | private void formHierarchyChanged(java.awt.event.HierarchyEvent evt) {//GEN-FIRST:event_formHierarchyChanged 161 | // TODO add your handling code here: 162 | }//GEN-LAST:event_formHierarchyChanged 163 | 164 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 165 | // TODO add your handling code here: 166 | }//GEN-LAST:event_jButton1ActionPerformed 167 | 168 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed 169 | // TODO add your handling code here: 170 | }//GEN-LAST:event_jButton2ActionPerformed 171 | 172 | /** 173 | * @param args the command line arguments 174 | */ 175 | public static void main(String args[]) { 176 | /* Set the Nimbus look and feel */ 177 | // 178 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 179 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 180 | */ 181 | try { 182 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 183 | if ("Nimbus".equals(info.getName())) { 184 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 185 | break; 186 | } 187 | } 188 | } catch (ClassNotFoundException ex) { 189 | java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 190 | } catch (InstantiationException ex) { 191 | java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 192 | } catch (IllegalAccessException ex) { 193 | java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 194 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 195 | java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 196 | } 197 | // 198 | 199 | /* Create and display the form */ 200 | java.awt.EventQueue.invokeLater(new Runnable() { 201 | public void run() { 202 | new LoginForm().setVisible(true); 203 | } 204 | }); 205 | } 206 | 207 | // Variables declaration - do not modify//GEN-BEGIN:variables 208 | private javax.swing.JButton jButton1; 209 | private javax.swing.JButton jButton2; 210 | private javax.swing.JLabel jLabel1; 211 | private javax.swing.JLabel jLabel2; 212 | private javax.swing.JLabel jLabel3; 213 | private javax.swing.JPanel jPanel1; 214 | private javax.swing.JPasswordField jPasswordField1; 215 | private javax.swing.JPopupMenu jPopupMenu1; 216 | private javax.swing.JTextField jTextField1; 217 | // End of variables declaration//GEN-END:variables 218 | } 219 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Connnect the java file to Database file using database connector..........! 2 | 3 | Installing Steps for MySql Database Connector: 4 | 5 | 1) First go to this page : https://dev.mysql.com/downloads/connector/j/ 6 | 2) Choose Platform Independent. 7 | 3) Choose This [Platform Independent (Architecture Independent), ZIP Archive] 8 | 4) And Click On [No thanks, just start my download] 9 | 10 | -------------------------------------------------------------------------------- /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 | <Editor/> 145 | <Renderer/> 146 | </Column> 147 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 148 | <Title/> 149 | <Editor/> 150 | <Renderer/> 151 | </Column> 152 | </TableColumnModel> 153 | </Property> 154 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 155 | <TableHeader reorderingAllowed="true" resizingAllowed="true"/> 156 | </Property> 157 | </Properties> 158 | </Component> 159 | </SubComponents> 160 | </Container> 161 | </SubComponents> 162 | </Container> 163 | <Container class="javax.swing.JPanel" name="jPanel3"> 164 | <Properties> 165 | <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> 166 | <Color blue="ff" green="cc" red="0" type="rgb"/> 167 | </Property> 168 | </Properties> 169 | 170 | <Layout> 171 | <DimensionLayout dim="0"> 172 | <Group type="103" groupAlignment="0" attributes="0"> 173 | <Group type="102" attributes="0"> 174 | <EmptySpace min="-2" pref="56" max="-2" attributes="0"/> 175 | <Component id="deplist" min="-2" max="-2" attributes="0"/> 176 | <EmptySpace pref="55" max="32767" attributes="0"/> 177 | </Group> 178 | </Group> 179 | </DimensionLayout> 180 | <DimensionLayout dim="1"> 181 | <Group type="103" groupAlignment="0" attributes="0"> 182 | <Group type="102" alignment="0" attributes="0"> 183 | <EmptySpace min="-2" pref="89" max="-2" attributes="0"/> 184 | <Component id="deplist" min="-2" max="-2" attributes="0"/> 185 | <EmptySpace max="32767" attributes="0"/> 186 | </Group> 187 | </Group> 188 | </DimensionLayout> 189 | </Layout> 190 | <SubComponents> 191 | <Component class="javax.swing.JButton" name="deplist"> 192 | <Properties> 193 | <Property name="text" type="java.lang.String" value="List All"/> 194 | </Properties> 195 | <Events> 196 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deplistActionPerformed"/> 197 | </Events> 198 | </Component> 199 | </SubComponents> 200 | </Container> 201 | </SubComponents> 202 | </Form> 203 | -------------------------------------------------------------------------------- /department.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JPanel.java to edit this template 4 | */ 5 | package task; 6 | 7 | 8 | import java.sql.*; 9 | import javax.swing.table.DefaultTableModel; 10 | 11 | /** 12 | * 13 | * @author sangs 14 | */ 15 | public class department extends javax.swing.JPanel { 16 | /** 17 | * Creates new form department 18 | */ 19 | public department() { 20 | initComponents(); 21 | } 22 | 23 | /** 24 | * This method is called from within the constructor to initialize the form. 25 | * WARNING: Do NOT modify this code. The content of this method is always 26 | * regenerated by the Form Editor. 27 | */ 28 | @SuppressWarnings("unchecked") 29 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 30 | private void initComponents() { 31 | 32 | jPanel1 = new javax.swing.JPanel(); 33 | jLabel1 = new javax.swing.JLabel(); 34 | jPanel2 = new javax.swing.JPanel(); 35 | jScrollPane2 = new javax.swing.JScrollPane(); 36 | deptable = new javax.swing.JTable(); 37 | jPanel3 = new javax.swing.JPanel(); 38 | deplist = new javax.swing.JButton(); 39 | 40 | setBackground(new java.awt.Color(153, 153, 153)); 41 | 42 | jPanel1.setBackground(new java.awt.Color(204, 0, 255)); 43 | 44 | jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N 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(39, 39, 39) 53 | .addComponent(jLabel1) 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(30, 30, 30) 60 | .addComponent(jLabel1) 61 | .addContainerGap(32, Short.MAX_VALUE)) 62 | ); 63 | 64 | jPanel2.setBackground(new java.awt.Color(204, 255, 255)); 65 | 66 | deptable.setModel(new javax.swing.table.DefaultTableModel( 67 | new Object [][] { 68 | {null, null}, 69 | {null, null}, 70 | {null, null} 71 | }, 72 | new String [] { 73 | "Depatment Id", "Department Name" 74 | } 75 | )); 76 | jScrollPane2.setViewportView(deptable); 77 | 78 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 79 | jPanel2.setLayout(jPanel2Layout); 80 | jPanel2Layout.setHorizontalGroup( 81 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 82 | .addGroup(jPanel2Layout.createSequentialGroup() 83 | .addContainerGap() 84 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 85 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 86 | ); 87 | jPanel2Layout.setVerticalGroup( 88 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 89 | .addGroup(jPanel2Layout.createSequentialGroup() 90 | .addContainerGap() 91 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) 92 | .addContainerGap(196, Short.MAX_VALUE)) 93 | ); 94 | 95 | jPanel3.setBackground(new java.awt.Color(0, 204, 255)); 96 | 97 | deplist.setText("List All"); 98 | deplist.addActionListener(new java.awt.event.ActionListener() { 99 | public void actionPerformed(java.awt.event.ActionEvent evt) { 100 | deplistActionPerformed(evt); 101 | } 102 | }); 103 | 104 | javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); 105 | jPanel3.setLayout(jPanel3Layout); 106 | jPanel3Layout.setHorizontalGroup( 107 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 108 | .addGroup(jPanel3Layout.createSequentialGroup() 109 | .addGap(56, 56, 56) 110 | .addComponent(deplist) 111 | .addContainerGap(55, Short.MAX_VALUE)) 112 | ); 113 | jPanel3Layout.setVerticalGroup( 114 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 115 | .addGroup(jPanel3Layout.createSequentialGroup() 116 | .addGap(89, 89, 89) 117 | .addComponent(deplist) 118 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 119 | ); 120 | 121 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 122 | this.setLayout(layout); 123 | layout.setHorizontalGroup( 124 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 125 | .addGroup(layout.createSequentialGroup() 126 | .addContainerGap() 127 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 128 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 129 | .addGroup(layout.createSequentialGroup() 130 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 131 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 132 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) 133 | .addContainerGap()) 134 | ); 135 | layout.setVerticalGroup( 136 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 137 | .addGroup(layout.createSequentialGroup() 138 | .addContainerGap() 139 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 140 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 141 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 142 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 143 | .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 144 | .addContainerGap()) 145 | ); 146 | }// </editor-fold>//GEN-END:initComponents 147 | 148 | private void deplistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deplistActionPerformed 149 | // TODO add your handling code here: 150 | DefaultTableModel model = (DefaultTableModel)deptable.getModel(); 151 | try{ 152 | //step1 load the driver class 153 | Class.forName("com.mysql.cj.jdbc.Driver"); 154 | //step2 create the connection object 155 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/department", "root","Karthi@0510"); 156 | //step3 create the statement object 157 | Statement stmt=con.createStatement(); 158 | 159 | //step4 execute query 160 | //ResultSet rs=stmt.executeQuery("create table employee (empid number(4), empname varchar2(25))"); 161 | //stmt.executeUpdate("insert into dep_info values(3, 'EEE')"); 162 | //stmt.executeUpdate("update dep_info set dep_name = 'CSE' where id=2"); 163 | ResultSet rs=(ResultSet) stmt.executeQuery("select * from dep_info"); 164 | while(rs.next()){ 165 | Object[] data = {rs.getInt(1),rs.getString(2)}; 166 | model.addRow(data); 167 | } 168 | //System.out.println(rs.getInt(1)+" "+rs.getString(2)); 169 | //stmt.executeUpdate("delete from dep_info where id=3"); 170 | //step5 close the connection object 171 | con.close(); 172 | }catch(ClassNotFoundException | SQLException e){ System.out.println(e);} 173 | }//GEN-LAST:event_deplistActionPerformed 174 | 175 | public static void main(String args[]) { 176 | /* Set the Nimbus look and feel */ 177 | //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> 178 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 179 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 180 | */ 181 | try { 182 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 183 | if ("Nimbus".equals(info.getName())) { 184 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 185 | break; 186 | } 187 | } 188 | } catch (ClassNotFoundException ex) { 189 | java.util.logging.Logger.getLogger(Dept.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 190 | } catch (InstantiationException ex) { 191 | java.util.logging.Logger.getLogger(Dept.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 192 | } catch (IllegalAccessException ex) { 193 | java.util.logging.Logger.getLogger(Dept.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 194 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 195 | java.util.logging.Logger.getLogger(Dept.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 196 | } 197 | //</editor-fold> 198 | 199 | /* Create and display the form */ 200 | java.awt.EventQueue.invokeLater(new Runnable() { 201 | public void run() { 202 | new department().setVisible(true); 203 | } 204 | }); 205 | } 206 | 207 | 208 | // Variables declaration - do not modify//GEN-BEGIN:variables 209 | private javax.swing.JButton deplist; 210 | private javax.swing.JTable deptable; 211 | private javax.swing.JLabel jLabel1; 212 | private javax.swing.JPanel jPanel1; 213 | private javax.swing.JPanel jPanel2; 214 | private javax.swing.JPanel jPanel3; 215 | private javax.swing.JScrollPane jScrollPane2; 216 | // End of variables declaration//GEN-END:variables 217 | } 218 | -------------------------------------------------------------------------------- /sql.sql: -------------------------------------------------------------------------------- 1 | create database department; 2 | use department; 3 | create table dep_info(dep_id int, dep_name varchar(10)); 4 | desc dep_info; 5 | create table student(roll_no int primary key, stu_name varchar(50)); 6 | desc student; 7 | 8 | alter table student 9 | add column age int; 10 | 11 | desc student; 12 | 13 | insert into dep_info(dep_code,dep_name) 14 | values(1,"AIML"); 15 | 16 | select * from dep_info; 17 | 18 | insert into dep_info values 19 | (2, "AIDS"), 20 | (3, "CSE"); 21 | 22 | update dep_info 23 | set dep_name = "EEE" 24 | where id = 3; 25 | 26 | delete from dep_info 27 | where id = 3; 28 | 29 | select * from dep_info; 30 | 31 | 32 | --------------------------------------------------------------------------------