[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

using combobox to retrieve data from oracle database

can anyone please help me out i am trying to retrieve data from my database using a combo box i am not sure about the steps i have taken to retrieve the data. i have my connection working(so pls dont write about the connection)



public class Combo extends JFrame implements ActionListener
{
     
       
        JComboBox updatecombo;


//CREATE THE USER INTERFACE
void makeGUI(){
JFrame f = new JFrame ("Main Frame");
f.setSize(350, 250);

cPanel = new JPanel(new GridBagLayout());

updatecombo = new JComboBox();
cPanel.add(updatecombo);


updatecombo.addActionListener(this);

}
public void actionPerformed(ActionEvent e)
{


     if (e.getSource() == updatecombo) {      
     String query = "SELECT TITLE FROM BOOKS_IN_STOCK";
     pstmt = connection.createStatement();
    rs = pstmt.executeQuery(query);
                  
   updatecombo codelist= new updatecombo(); //Not sure about this line
                        
    while(rs.next())
    {
    codelist.add(rs.getString("TITLE"));      
    }
}//end if
}
}

0
lucinda77
Asked:
lucinda77
1 Solution
 
lubovecCommented:
try to change this part of code

//
   updatecombo codelist= new updatecombo(); //Not sure about this line
                   
    while(rs.next())
    {
    codelist.add(rs.getString("TITLE"));    
    }
//

to

//
    while(rs.next())
    {
    updatecombo.add(rs.getString("TITLE"));    
    }
//

updatecombo is variable, not a class
i think... ;)

gl
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now