Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to resolve casting error in my Java program

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 264
    Answer it

    I am trying to get data from a database using 3 Jcomboboxes and then put the data in a Jtable and i am getting a empID=(int)employees[selectedIndex-1][1]; 

    public void updateTable()
      {
        int selectedIndex=employeeCmb.getSelectedIndex();
        int empID;
        if (selectedIndex==0)
          empID =-1;
        else
          empID=(int)employees[selectedIndex-1][1];
        String adate=dateLbl.getText();
        
        q.connectToDatabase();
        empAppointments=q.getEmpAppointments_OA(empID,adate);
        int appCount=empAppointments.length;
        
        Object [][]empAppointments2 = new Object[appCount][4];
        for (int i =0; i < appCount; i++)
        {
          for (int j=0; j < 4;j++)
          {
            empAppointments2[i][j]=empAppointments[i][j];
            model=new DefaultTableModel(empAppointments2,colNames);
            table.setModel(model);
            q.disconnectFromDatabase();
         //    System.out.println(colNames);
          }
        }
      }
       
       
      public void actionPerformed(ActionEvent e)
      {
        if(e.getSource()==insBtn)
        {
           updateTable();
          
        }
        else if (e.getSource()==nextBtn)
        {
         l=l+86400000;
         d=new Date(l);
         s=sdf.format(d);
         dateLbl.setText(s);      
        }
         
        else if (e.getSource()==preBtn)
        {
          l=l-86400000;
          d=new Date(l);
          s=sdf.format(d);
          dateLbl.setText(s); 
        }
       
        else if (e.getSource()==delBtn)
        {
        int deleted=q.deleteOneClient(4);
       
       
       
        }
       
        else if(e.getSource()==updBtn)
        {
       int inserted=q.insertOneClient("ali","rahim","123 Some Rd","ddd@eee","3456777");
       
       
        }
      }
    
      public static void main(String[] args)
      {
       Queries q = new Queries();
       new BookingCard();
      }
    
    
    }

     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: