ඉක්මනින්ම Database එකට Data Insert කිරීම හා Data Update කිරීම සඳහා Form එකක් (Vehicle Insert, Update සඳහා) නිර්මාණය කරගන්න හැටි බලමු.
සැ.යු. - Interface Design එක ගැන සලකා නැත. මුලිකම පෙනුම පමණි.
එක් එක් coding කුමක් සඳහාද යන්න තේරුම් ගැනීම ඔබ
සතුය.
Quick - Insert, Update Data of mySQL DB, through NetBeans Form
Download File Size - 8.78MB
After Extract File - 891MB
Duration - 19min 11s
http://www.mediafire.com/?l9jgbaer6wgl0tb
//////////////////////////////////////////////////////////////////////
public Vehicles(String recievedname) {
initComponents();
name = recievedname;
showallvehicles();
}
final void showallvehicles(){
try {
ResultSet rst = DB_Access.getData("select * from vehicle");
DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
int rows = dtm.getRowCount();
for(int i=0;i<rows;i++){
dtm.removeRow(0);
}
while(rst.next()){
Object ob[] = {rst.getString(1),rst.getString(2),rst.getString(3),rst.getString(4)};
dtm.addRow(ob);
}
} catch (SQLException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try {
DB_Access.setData("insert into vehicle values ('"+jTextField1.getText()+"','"+jTextField2.getText()+"','"+jTextField3.getText()+"','"+jTextField4.getText()+"')");
JOptionPane.showMessageDialog(this, "Insert Successfull");
showallvehicles();
} catch (SQLException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
}
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
jTextField8.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString());
jTextField7.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString());
jTextField6.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 2).toString());
jTextField5.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 3).toString());
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
try {
DB_Access.setData("update vehicle set driver='"+jTextField7.getText()+"', no_of_seats='"+jTextField5.getText()+"' where reg_no='"+jTextField8.getText()+"'");
JOptionPane.showMessageDialog(this, "Update Successfully");
showallvehicles();
} catch (SQLException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Vehicles.class.getName()).log(Level.SEVERE, null, ex);
}
}
කොහොම හරි ගොඩයන්න පෙරලෙන පිටු
ලේසියෙන්ම හොයාගන්න මෙතනින්
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment