hi pple
how are you all, I am doing a car rental management system project, not a school assignment but something i am practicing on. I am currently some codes it will allow the program to delete any record that may not be relevant anymore but for some reason, I am getting an error with the delete record and also another error I am experiencing is with the UIManage.getSystemLookandFeel method. can some explain it to me and how to go about fixing it .
here is the codes.
the error is: unreported exception ClassNotFoundException; must be caught or declared to be thrown
what does this mean and how do i fix this
package Rental_Services;
import java.sql.SQLException;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.DefaultTableCellRenderer;
/**
*
* @author luana
*/
public class listofstaff extends javax.swing.JFrame {
boolean addRecord = false;
private void clearInputBoxesstatic() {
jtxt_empIDNum.setText("");
jtxt_fullName.setText("");
cboGender.setSelectedItem("");
jtxt_depart.setText("");
jtxt_position.setText("");
jtxt_salary.setText("");
}
private void addNew() throws SQLException{
String sql_stmt = "INSERT INTO employees (fullName, gender, department, position, salary)";
sql_stmt += " VALUES ('" + jtxt_fullName.getText() + "','" + cboGender.getSelectedItem().toString() + "','" + jtxt_depart.getText() + "','" + jtxt_position.getText() + "','" + jtxt_salary.getText() + "')";
DBUtilities dbu= new DBUtilities();
dbu.ExecuteSQLStatement(sql_stmt);
}
private void updateRecord() throws SQLException{
String sql_stmt = "UPDATE employees SET full_name = '" + jtxt_fullName.getText() + "'";
sql_stmt +=",gender = '" + cboGender.getSelectedItem().toString() + "'";
sql_stmt += ", department" + jtxt_depart.getText() + "'";
sql_stmt += ",position" + jtxt_position.getText() + "'";
sql_stmt += ",salary" + jtxt_salary.getText() + "'";
sql_stmt += "WHERE empIDNum = " + jtxt_empIDNum.getText() + "'";
DBUtilities dbu = new DBUtilities();
dbu.ExecuteSQLStatement(sql_stmt);
}
private void deletRecord() throws SQLException{
String sql_stmt = "DELET FROM employess WHERE employees_IDNum = " + jtxt_empIDNum.getText() + "'";
DBUtilities dbu = new DBUtilities();
dbu.ExecuteSQLStatement(sql_stmt);
}
private void loadRecord() throws SQLException{
String sql_stmt = " SELECT * FROM employees; ";
ResultSetTableModel rstm = new ResultSetTableModel(sql_stmt);
jTab1.setModel(rstm);
jTab1.getSelectionModel().addListSelectionListener((ListSelectionEvent event) -> {
try {
if (jTab1.getSelectedRow() >= 0) {
Object employee_id = jTab1.getValueAt(jTab1.getSelectedRow(), 0);
Object full_name = jTab1.getValueAt(jTab1.getSelectedRow(), 1);
Object gender = jTab1.getValueAt(jTab1.getSelectedRow(), 2);
Object department = jTab1.getValueAt(jTab1.getSelectedRow(), 3);
Object position = jTab1.getValueAt(jTab1.getSelectedRow(), 4);
Object salary = jTab1.getValueAt(jTab1.getSelectedRow(), 5);
jtxt_empIDNum.setText(employee_id.toString());
jtxt_fullName.setText(full_name.toString());
cboGender.setSelectedItem(gender.toString());
jtxt_depart.setText(department.toString());
jtxt_position.setText(position.toString());
jtxt_salary.setText(salary.toString());
}
} catch (Exception ex) {
//System.out.println(ex.getMessage());
}
});
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(SwingConstants.LEFT);
jTab1.getColumnModel().getColumn(0).setCellRenderer(rightRenderer);
}
public listofstaff() {
initComponents();
}
private void jbtnAddNewActionPerformed(java.awt.event.ActionEvent evt) {
addRecord = true;
//clearInputBoxes();
jtxt_fullName.requestFocus();
}
private void jbtnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
int dialogResult = JOptionPane.showConfirmDialog(null, "Are you sure you want to update this record?", "confirm update record", JOptionPane.YES_NO_OPTION);
if(dialogResult == JOptionPane.YES_NO_OPTION)
{
try{
if(addRecord == true)
{
addNew();
}
else
{
updateRecord();
}
addRecord = false;
loadRecord();
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
}
private void jbtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int dialogResult = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this record?");
if(dialogResult == JOptionPane.YES_NO_OPTION)
{
try
{
//deleteRecord(); <---- this is the error
loadRecord();
}
catch(SQLException ex)
{
System.out.println(ex.getMessage());
}
}
}
this is the other error am getting
public class Employees {
// set the system l & f
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());<---- the error is right here
}
catch(SQLException ex)
{
}
Employees emp = new Employees();

