Professional Documents
Culture Documents
Informatics Practices Practical File
Informatics Practices Practical File
Informatics Practices
Practical File
Anurag Kumar
Class: XII Science
School: K V No 1 Bathinda Cantt
Session: 2010 - 2011
Roll No.:
private void emptyBTNActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
DefaultTableModel model = (DefaultTableModel)empTbl.getModel();
int rows = model.getRowCount();
//now remove all components of table
if (rows>0){
for(int i=0;i<rows;i++){
model.removeRow(0);
}
}
}
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in Connectivity");
}
Name Of Field Variable Name Font Items Text
Search Criteria Application on Database employee
Label 1 title Tahoma18 bold - Write Required
Query
Label 2 search Tahoma 14 - Search Field
bold
Label3 critLbl Tahoma 14 - Criteria
bold
TextField1 critTF Tahoma 14 -
bold
ComboBox 1 srchFldCBX Tahoma 8 Empno,ename,job, -
sal,deptno
ComboBox2 opCBX Tahoma 8 =,<,>,!= -
public class record_load extends javax.swing.JFrame {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
/** Creates new form record_load */
public record_load() {
initComponents();
}
private void loadBTNActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee","root","a");
stmt = con.createStatement();
String dep = depnoTF.getText();
String query = "SELECT * From dept where deptno"+dep+";";
rs = stmt.executeQuery(query);
if (rs.next()){
String dno = rs.getString("depno");
String dname = rs.getString("dname");
String lc = rs.getString("loc");
dnameTF.setText(dname);
locTF.setText(lc);
updBtn.setEnabled(true);
delBTN.setEnabled(true);
dnameTF.setEnabled(true);
locTF.setEnabled(true);
}
else {
JOptionPane.showMessageDialog(null,"No Such Record Found");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in Connectivity");
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Record Susscefully Updated");
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in Connectivity");
dnameTF.setText("");
depnoTF.setText("");
locTF.setText("");
updBtn.setEnabled(false);
delBTN.setEnabled(false);
}
}
}
private void delBTNActionPerformed(java.awt.event.ActionEvent evt) {
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Record Susscefully Deleted");
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in deletion!");
}
}
dnameTF.setText("");
depnoTF.setText("");
locTF.setText("");
updBtn.setEnabled(false);
delBTN.setEnabled(false);
}
Name Of Field Variable Name Font Items Text
Updating/Deleting Table
Label 1 depnolbl Tahoma14 bold - DeptNo
Label 2 Depnamelbl Tahoma 14 - Dep-Name
bold
Label3 Loclbl Tahoma 14 - Location
bold
TextField1 depnoTF Tahoma 14 -
bold
TextField2 dnameTF Tahoma 8 -
TextField3 locTF Tahoma 8 -
Button 1 Loadbtn Tahoma 12 - Load Btn
Button 2 updBtn Tahoma 12 - Update Record
Button 3 delBtn Tahoma 12 - Delete Record
At the top of the code write :
Import java.util.Random;
Then
TypeArea.copy();
TypeArea.paste();
TypeArea.cut();
}
Name Of Field Variable Name Font Border Text
Main Form
Button1 cutBtn Tahoma 20 bold - Cut
Button2 copyBtn Tahoma 20bold - Copy
Button3 pasteBtn Tahoma 20 bold - Paste
TextArea1 Typearea Tahoma 12 -
private void tagoalbtnActionPerformed(java.awt.event.ActionEvent evt) {